1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use crate::attachment::Attachment;
/// User's relationship with another user (or themselves)
#[derive(Deserialize, Debug, Clone, PartialEq)]
pub enum RelationshipStatus {
None,
User,
Friend,
Outgoing,
Incoming,
Blocked,
BlockedOther,
}
/// Relationship entry indicating current status with other user
#[derive(Deserialize, Debug, Clone)]
pub struct Relationship {
#[serde(rename = "_id")]
pub id: String,
pub status: RelationshipStatus,
}
/// Mutual servers and friends
#[derive(Deserialize, Debug, Clone)]
pub struct Mutuals {
/// Array of mutual user IDs that both users are friends with
pub users: Vec<String>,
/// Array of mutual server IDs that both users are in
pub servers: Vec<String>,
}
/// Presence status
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub enum Presence {
/// User is online
Online,
/// User is not currently available
Idle,
/// User is focusing / will only receive mentions
Focus,
/// User is busy / will not receive any notifications
Busy,
/// User appears to be offline
Invisible,
}
/// User's active status
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct UserStatus {
/// Custom status text
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
/// Current presence option
#[serde(skip_serializing_if = "Option::is_none")]
pub presence: Option<Presence>,
}
/// User's profile
#[derive(Deserialize, Debug, Clone, Default)]
pub struct UserProfile {
/// Text content on user's profile
pub content: Option<String>,
/// Background visible on user's profile
pub background: Option<Attachment>,
}
/// Partial user's profile
///
/// This object not contains additional background attachment data
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct PartialUserProfile {
/// Text to set as user profile description
#[serde(skip_serializing_if = "Option::is_none")]
content: Option<String>,
/// Attachment Id for background
#[serde(skip_serializing_if = "Option::is_none")]
background: Option<String>,
}
bitflags::bitflags! {
/// User badge bitfield
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Badges: u64 {
/// Revolt Developer
const Developer = 1 << 0;
/// Helped translate Revolt
const Translator = 1 << 1;
/// Monetarily supported Revolt
const Supporter = 1 << 2;
/// Responsibly disclosed a security issue
const ResponsibleDisclosure = 1 << 3;
/// Revolt Founder
const Founder = 1 << 4;
/// Platform moderator
const PlatformModeration = 1 << 5;
/// Active monetary supporter
const ActiveSupporter = 1 << 6;
/// 🦊🦝
const Paw = 1 << 7;
/// Joined as one of the first 1000 users in 2021
const EarlyAdopter = 1 << 8;
/// Amogus
const ReservedRelevantJokeBadge1 = 1 << 9;
/// Low resolution troll face
const ReservedRelevantJokeBadge2 = 1 << 10;
}
}
crate::impl_serde_bitflags!(Badges);
bitflags::bitflags! {
/// User flag enum
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct UserFlags: u64 {
/// User has been suspended from the platform
const Suspended = 1;
/// User has deleted their account
const Deleted = 2;
/// User was banned off the platform
const Banned = 4;
/// User was marked as spam and removed from platform
const Spam = 8;
}
}
crate::impl_serde_bitflags!(UserFlags);
/// Bot information for if the user is a bot
#[derive(Deserialize, Debug, Clone)]
pub struct BotInformation {
/// Id of the owner of this bot
pub owner: String,
}
/// Representiation of a User on Revolt.
#[derive(Deserialize, Debug, Clone)]
pub struct User {
/// Unique Id
#[serde(rename = "_id")]
pub id: String,
/// Username
pub username: String,
/// User discriminator (four numbers after the username)
pub discriminator: String,
/// User's display name
pub display_name: Option<String>,
/// Avatar attachment
pub avatar: Option<Attachment>,
/// Relationships with other users
pub relations: Option<Vec<Relationship>>,
/// Bitfield of user badges
pub badges: Option<i32>,
/// User's current status
pub status: Option<UserStatus>,
/// User's profile page
pub profile: Option<UserProfile>,
/// Enum of user flags
pub flags: Option<UserFlags>,
/// Whether this user is privileged
#[serde(default)]
pub privileged: bool,
/// Bot information
pub bot: Option<BotInformation>,
/// Current session user's relationship with this user
pub relationship: Option<RelationshipStatus>,
/// Whether this user is currently online
pub online: Option<bool>,
}
/// Partial representiation of a User on Revolt.
#[derive(Deserialize, Debug, Clone)]
pub struct PartialUser {
/// Unique Id
#[serde(rename = "_id")]
pub id: Option<String>,
/// Username
pub username: Option<String>,
/// User discriminator
pub discriminator: Option<String>,
/// Display name
pub display_name: Option<String>,
/// Avatar attachment
pub avatar: Option<Attachment>,
/// Relationships with other users
pub relations: Option<Vec<Relationship>>,
/// Bitfield of user badges
pub badges: Option<i32>,
/// User's current status
pub status: Option<UserStatus>,
/// User's profile page
pub profile: Option<UserProfile>,
/// Enum of user flags
pub flags: Option<UserFlags>,
/// Whether this user is privileged
pub privileged: Option<bool>,
/// Bot information
pub bot: Option<BotInformation>,
/// Current session user's relationship with this user
pub relationship: Option<RelationshipStatus>,
/// Whether this user is currently online
pub online: Option<bool>,
}
/// Optional fields on user object
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
pub enum FieldsUser {
Avatar,
StatusText,
StatusPresence,
ProfileContent,
ProfileBackground,
DisplayName,
}
/// HashMap of user settings
/// Each key is mapped to a tuple consisting of the
/// revision timestamp and serialised data (in JSON format)
pub type UserSettings = HashMap<String, (i64, String)>;