steam_user/types/activity.rs
1//! Types for Friend Activity Feed operations.
2
3use serde::{Deserialize, Serialize};
4use steamid::SteamID;
5
6/// Type of activity in the friend activity feed.
7#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
8#[non_exhaustive]
9#[derive(Default)]
10pub enum ActivityType {
11 /// Two users became friends.
12 NewFriend,
13 /// User played a game for the first time.
14 PlayedFirstTime,
15 /// User earned an achievement.
16 Achieved,
17 /// User added a game to their wishlist.
18 AddedToWishlist,
19 /// User started following another user.
20 Following,
21 /// User joined a group.
22 Joined,
23 /// User purchased/received a game.
24 GamePurchase,
25 /// User published a workshop item.
26 WorkshopItemPublished,
27 /// User posted a recommendation/review.
28 Recommendation,
29 /// User posted a status update.
30 UserStatus,
31 /// User shared a screenshot.
32 Screenshot,
33 /// User published a video.
34 VideoPublished,
35 /// Daily activity rollup (aggregated activities).
36 #[default]
37 DailyRollup,
38 /// Unknown activity type.
39 Unknown(String),
40}
41
42/// A player reference in an activity.
43#[derive(Debug, Clone, Default, Serialize, Deserialize)]
44pub struct ActivityPlayer {
45 /// Player's display name.
46 pub name: String,
47 /// Player's nickname (friend nickname set by you).
48 pub nickname: Option<String>,
49 /// Player's miniprofile ID.
50 pub miniprofile: u64,
51 /// Player's SteamID.
52 pub steam_id: SteamID,
53}
54
55/// An app/game reference in an activity.
56#[derive(Debug, Clone, Default, Serialize, Deserialize)]
57pub struct ActivityApp {
58 /// App ID.
59 pub id: u32,
60 /// App name.
61 pub name: String,
62 /// Link to the app's store/community page.
63 pub link: String,
64}
65
66/// An achievement earned in an activity.
67#[derive(Debug, Clone, Default, Serialize, Deserialize)]
68pub struct ActivityAchievement {
69 /// Achievement title/name.
70 pub title: String,
71 /// Achievement icon URL.
72 pub img: String,
73}
74
75/// A group reference in an activity.
76#[derive(Debug, Clone, Default, Serialize, Deserialize)]
77pub struct ActivityGroup {
78 /// Group name.
79 pub name: String,
80 /// Full link to the group.
81 pub link: String,
82 /// Group URL slug (e.g., "mygroup" from steamcommunity.com/groups/mygroup).
83 pub url: String,
84}
85
86/// A comment on an activity item.
87#[derive(Debug, Clone, Default, Serialize, Deserialize)]
88pub struct ActivityComment {
89 /// Comment ID.
90 pub id: String,
91 /// Author's SteamID.
92 pub author_steam_id: SteamID,
93 /// Author's miniprofile ID.
94 pub author_miniprofile: u64,
95 /// Author's avatar hash.
96 pub author_avatar_hash: String,
97 /// Comment timestamp (Unix seconds).
98 pub timestamp: u64,
99}
100
101/// Author of an activity (for game purchases, etc.).
102#[derive(Debug, Clone, Default, Serialize, Deserialize)]
103pub struct ActivityAuthor {
104 /// Author's display name.
105 pub name: String,
106 /// Author's nickname (friend nickname set by you).
107 pub nickname: Option<String>,
108 /// Author's avatar hash.
109 pub avatar_hash: String,
110 /// Author's miniprofile ID.
111 pub miniprofile: u64,
112 /// Author's SteamID.
113 pub steam_id: SteamID,
114 /// Author's profile URL.
115 pub profile_url: String,
116 /// Author's custom URL (if set).
117 pub custom_url: Option<String>,
118}
119
120/// A single activity item from the friend activity feed.
121#[derive(Debug, Clone, Default, Serialize, Deserialize)]
122pub struct FriendActivity {
123 /// Type of activity.
124 pub activity_type: ActivityType,
125 /// Timestamp of the activity (Unix seconds).
126 pub timestamp: u64,
127 /// Human-readable date header (e.g., "January 10").
128 pub header_date: String,
129 /// Players involved in this activity (for daily rollups).
130 pub players: Vec<ActivityPlayer>,
131 /// Apps/games involved in this activity.
132 pub apps: Vec<ActivityApp>,
133 /// Groups involved in this activity.
134 pub groups: Vec<ActivityGroup>,
135 /// Achievements earned (if applicable).
136 pub achieved: Vec<ActivityAchievement>,
137 /// Author of the activity (for game purchases).
138 pub author: Option<ActivityAuthor>,
139 /// Thread ID for commenting on this activity.
140 pub thread_id: Option<u64>,
141 /// Comments on this activity.
142 pub comments: Vec<ActivityComment>,
143}
144
145/// Response from getting the friend activity feed.
146#[derive(Debug, Clone, Default, Serialize, Deserialize)]
147pub struct FriendActivityResponse {
148 /// List of activities.
149 pub activities: Vec<FriendActivity>,
150 /// Next request timestamp for pagination.
151 pub next_request_timestart: Option<u64>,
152 /// Next request URL for pagination.
153 pub next_request_url: Option<String>,
154}
155
156/// Response from commenting/rating an activity.
157#[derive(Debug, Clone, Default, Serialize, Deserialize)]
158pub struct ActivityCommentResponse {
159 /// Whether the operation was successful.
160 pub success: bool,
161 /// Total number of comments.
162 pub total_count: u32,
163 /// Number of upvotes on the activity.
164 pub upvotes: u32,
165 /// Whether the current user has upvoted.
166 pub has_upvoted: bool,
167}