rive_models/
data.rs

1use iso8601_timestamp::Timestamp;
2use serde::Serialize;
3
4use crate::{
5    bot::FieldsBot,
6    channel::{ChannelType, FieldsChannel},
7    embed::SendableEmbed,
8    emoji::EmojiParent,
9    member::FieldsMember,
10    message::{Interactions, Masquerade, MessageSort, Reply},
11    mfa::MFAData,
12    permission::{Override, Permission},
13    report::{ReportStatus, ReportedContent},
14    server::{Category, FieldsRole, FieldsServer, SystemMessageChannels},
15    user::{FieldsUser, PartialUserProfile, UserStatus},
16};
17
18#[allow(dead_code)]
19fn if_false(t: &bool) -> bool {
20    !t
21}
22
23#[derive(Serialize, Debug, Clone, Default)]
24pub struct SendMessageData {
25    /// Message content to send
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub content: Option<String>,
28    /// Attachments to include in message
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub attachments: Option<Vec<String>>,
31    /// Messages to reply to
32    #[serde(skip_serializing_if = "Option::is_none")]
33    pub replies: Option<Vec<Reply>>,
34    /// Embeds to include in message
35    ///
36    /// Text embed content contributes to the content length cap
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub embeds: Option<Vec<SendableEmbed>>,
39    /// Masquerade to apply to this message
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub masquerade: Option<Masquerade>,
42    /// Information about how this message should be interacted with
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub interactions: Option<Interactions>,
45}
46
47/// User data
48#[derive(Serialize, Debug, Clone, Default)]
49pub struct EditUserData {
50    /// New user status
51    #[serde(skip_serializing_if = "Option::is_none")]
52    pub status: Option<UserStatus>,
53    /// New user profile data
54    ///
55    /// This is applied as a partial.
56    #[serde(skip_serializing_if = "Option::is_none")]
57    pub profile: Option<PartialUserProfile>,
58    /// Attachment ID for avatar
59    #[serde(skip_serializing_if = "Option::is_none")]
60    pub avatar: Option<String>,
61    /// Fields to remove from user object
62    #[serde(skip_serializing_if = "Option::is_none")]
63    pub remove: Option<Vec<FieldsUser>>,
64}
65
66/// Change username data
67#[derive(Serialize, Debug, Clone)]
68pub struct ChangeUsernameData {
69    /// New username
70    pub username: String,
71    /// Current username password
72    pub password: String,
73}
74
75/// Send friend request data
76#[derive(Serialize, Debug, Clone)]
77pub struct SendFriendRequestData {
78    /// Friend's usernane
79    pub username: String,
80}
81
82/// Edit channel data
83#[derive(Serialize, Debug, Clone, Default)]
84pub struct EditChannelData {
85    /// Channel name
86    #[serde(skip_serializing_if = "Option::is_none")]
87    pub name: Option<String>,
88    /// Channel description
89    #[serde(skip_serializing_if = "Option::is_none")]
90    pub description: Option<String>,
91    /// Group owner
92    #[serde(skip_serializing_if = "Option::is_none")]
93    pub owner: Option<String>,
94    /// Icon attachment ID
95    #[serde(skip_serializing_if = "Option::is_none")]
96    pub icon: Option<String>,
97    /// Whether this channel is age-restricted
98    #[serde(skip_serializing_if = "Option::is_none")]
99    pub nsfw: Option<bool>,
100    /// Fields to remove
101    #[serde(skip_serializing_if = "Option::is_none")]
102    pub remove: Option<Vec<FieldsChannel>>,
103}
104
105/// Set role permission data data
106#[derive(Serialize, Debug, Clone, Default)]
107pub struct SetRolePermissionData {
108    /// Representation of a single permission override
109    pub permissions: Override,
110}
111
112/// Set role permission data data
113#[derive(Serialize, Debug, Clone)]
114#[serde(untagged)]
115pub enum SetDefaultPermissionData {
116    Value {
117        /// Permission values to set for members in a [`Channel::Group`]
118        ///
119        /// [`Channel::Group`]: crate::channel::Channel::Group
120        permissions: Permission,
121    },
122    Field {
123        /// Allow / deny values to set for members in this [`Channel::TextChannel`] or [`Channel::VoiceChannel`]
124        ///
125        /// [`Channel::TextChannel`]: crate::channel::Channel::TextChannel
126        /// [`Channel::VoiceChannel`]: crate::channel::Channel::VoiceChannel
127        permissions: Override,
128    },
129}
130
131/// Query parameters
132#[derive(Serialize, Debug, Clone, Default)]
133pub struct FetchMessagesData {
134    /// Maximum number of messages to fetch
135    ///
136    /// For fetching nearby messages, this is `(limit + 1)`.
137    #[serde(skip_serializing_if = "Option::is_none")]
138    pub limit: Option<i64>,
139    /// Message id before which messages should be fetched
140    #[serde(skip_serializing_if = "Option::is_none")]
141    pub before: Option<String>,
142    /// Message id after which messages should be fetched
143    #[serde(skip_serializing_if = "Option::is_none")]
144    pub after: Option<String>,
145    /// Message sort direction
146    #[serde(skip_serializing_if = "Option::is_none")]
147    pub sort: Option<MessageSort>,
148    /// Message id to search around
149    ///
150    /// Specifying 'nearby' ignores 'before', 'after' and 'sort'.
151    /// It will also take half of limit rounded as the limits to each side.
152    /// It also fetches the message ID specified.
153    #[serde(skip_serializing_if = "Option::is_none")]
154    pub nearby: Option<String>,
155    /// Whether to include user (and member, if server channel) objects
156    #[serde(skip_serializing_if = "Option::is_none")]
157    pub include_users: Option<bool>,
158}
159
160/// Search Parameters
161#[derive(Serialize, Debug, Clone, Default)]
162pub struct SearchForMessagesData {
163    /// Full-text search query
164    ///
165    /// See [MongoDB documentation](https://docs.mongodb.com/manual/text-search/#-text-operator) for more information.
166    pub query: String,
167
168    /// Maximum number of messages to fetch
169    #[serde(skip_serializing_if = "Option::is_none")]
170    pub limit: Option<i64>,
171    /// Message id before which messages should be fetched
172    #[serde(skip_serializing_if = "Option::is_none")]
173    pub before: Option<String>,
174    /// Message id after which messages should be fetched
175    #[serde(skip_serializing_if = "Option::is_none")]
176    pub after: Option<String>,
177    /// Message sort direction
178    ///
179    /// By default, it will be sorted by relevance.
180    #[serde(skip_serializing_if = "Option::is_none")]
181    pub sort: Option<MessageSort>,
182    /// Whether to include user (and member, if server channel) objects
183    #[serde(skip_serializing_if = "Option::is_none")]
184    pub include_users: Option<bool>,
185}
186
187/// Message details
188#[derive(Serialize, Debug, Clone, Default)]
189pub struct EditMessageData {
190    /// New message content
191    #[serde(skip_serializing_if = "Option::is_none")]
192    pub content: Option<String>,
193    /// Embeds to include in the message
194    #[serde(skip_serializing_if = "Option::is_none")]
195    pub embeds: Option<Vec<SendableEmbed>>,
196}
197
198/// Search parameters
199#[derive(Serialize, Debug, Clone)]
200pub struct BulkDeleteMessagesData {
201    /// Message IDs
202    pub ids: Vec<String>,
203}
204
205/// Reactions remove options
206#[derive(Serialize, Debug, Clone, Default)]
207pub struct RemoveReactionToMessageData {
208    /// Remove a specific user's reaction
209    #[serde(skip_serializing_if = "Option::is_none")]
210    pub user_id: Option<String>,
211    /// Remove all reactions
212    #[serde(skip_serializing_if = "Option::is_none")]
213    pub remove_all: Option<bool>,
214}
215
216/// Group create data
217#[derive(Serialize, Debug, Clone, Default)]
218pub struct CreateGroupData {
219    /// Group name
220    name: String,
221    /// Group description
222    description: Option<String>,
223    /// Array of user IDs to add to the group
224    ///
225    /// Must be friends with these users.
226    users: Vec<String>,
227    /// Whether this group is age-restricted
228    #[serde(skip_serializing_if = "Option::is_none")]
229    nsfw: Option<bool>,
230}
231
232/// Bot create data
233#[derive(Serialize, Debug, Clone)]
234pub struct CreateBotData {
235    /// Bot username
236    name: String,
237}
238
239/// Bot invite data
240#[derive(Serialize, Debug, Clone)]
241#[serde(untagged)]
242pub enum InviteBotData {
243    /// Invite to a server
244    Server {
245        /// Server Id
246        server: String,
247    },
248    /// Invite to a group
249    Group {
250        /// Group Id
251        group: String,
252    },
253}
254
255/// Bot edit data
256#[derive(Serialize, Debug, Clone, Default)]
257pub struct EditBotData {
258    /// Bot username
259    #[serde(skip_serializing_if = "Option::is_none")]
260    pub name: Option<String>,
261    /// Whether the bot can be added by anyone
262    #[serde(skip_serializing_if = "Option::is_none")]
263    pub public: Option<bool>,
264    /// Whether analytics should be gathered for this bot
265    ///
266    /// Must be enabled in order to show up on [Revolt Discover](https://rvlt.gg).
267    #[serde(skip_serializing_if = "Option::is_none")]
268    pub analytics: Option<bool>,
269    /// Interactions URL
270    #[serde(skip_serializing_if = "Option::is_none")]
271    pub interactions_url: Option<String>,
272    /// Fields to remove from bot object
273    #[serde(skip_serializing_if = "Option::is_none")]
274    pub remove: Option<Vec<FieldsBot>>,
275}
276
277/// Create server data
278#[derive(Serialize, Debug, Clone, Default)]
279pub struct CreateServerData {
280    /// Server name
281    pub name: String,
282    /// Server description
283    pub description: Option<String>,
284    /// Whether this server is age-restricted
285    #[serde(skip_serializing_if = "Option::is_none")]
286    pub nsfw: Option<bool>,
287}
288
289/// Edit server data
290#[derive(Serialize, Debug, Clone, Default)]
291pub struct EditServerData {
292    /// Server name
293    pub name: Option<String>,
294    /// Server description
295    pub description: Option<String>,
296
297    /// Attachment Id for icon
298    pub icon: Option<String>,
299    /// Attachment Id for banner
300    pub banner: Option<String>,
301
302    /// Category structure for server
303    pub categories: Option<Vec<Category>>,
304    /// System message configuration
305    pub system_messages: Option<SystemMessageChannels>,
306
307    // Whether this server is age-restricted
308    pub nsfw: Option<bool>,
309    /// Whether this server is public and should show up on [Revolt Discover](https://rvlt.gg)
310    pub discoverable: Option<bool>,
311    /// Whether analytics should be collected for this server
312    ///
313    /// Must be enabled in order to show up on [Revolt Discover](https://rvlt.gg).
314    pub analytics: Option<bool>,
315
316    /// Fields to remove from server object
317    pub remove: Option<Vec<FieldsServer>>,
318}
319
320/// Create channel data
321#[derive(Serialize, Debug, Clone, Default)]
322pub struct CreateChannelData {
323    /// Channel type
324    #[serde(rename = "type", default = "ChannelType::default")]
325    pub channel_type: ChannelType,
326    /// Channel name
327    pub name: String,
328    /// Channel description
329    pub description: Option<String>,
330    /// Whether this channel is age restricted
331    #[serde(skip_serializing_if = "Option::is_none")]
332    pub nsfw: Option<bool>,
333}
334
335/// Create emoji data
336#[derive(Serialize, Debug, Clone)]
337pub struct CreateEmojiData {
338    /// Server name
339    pub name: String,
340    /// Parent information
341    pub parent: EmojiParent,
342    /// Whether the emoji is mature
343    pub nsfw: bool,
344}
345
346/// Fetch settings data
347#[derive(Serialize, Debug, Clone)]
348pub struct FetchSettingsData {
349    /// Keys to fetch
350    pub keys: Vec<String>,
351}
352
353/// Web push subscription data
354#[derive(Serialize, Debug, Clone)]
355pub struct PushSubscribeData {
356    pub endpoint: String,
357    pub p256dh: String,
358    pub auth: String,
359}
360
361/// Create role data
362#[derive(Serialize, Debug, Clone, Default)]
363pub struct CreateRoleData {
364    /// Role name
365    pub name: String,
366    /// Ranking position
367    ///
368    /// Smaller values take priority.
369    #[serde(skip_serializing_if = "Option::is_none")]
370    pub rank: Option<i64>,
371}
372
373/// Edit role data
374#[derive(Serialize, Debug, Clone, Default)]
375pub struct EditRoleData {
376    /// Role name
377    #[serde(skip_serializing_if = "Option::is_none")]
378    pub name: Option<String>,
379    /// Role colour
380    #[serde(skip_serializing_if = "Option::is_none")]
381    pub colour: Option<String>,
382    /// Whether this role should be displayed separately
383    #[serde(skip_serializing_if = "Option::is_none")]
384    pub hoist: Option<bool>,
385    /// Ranking position
386    ///
387    /// Smaller values take priority.
388    #[serde(skip_serializing_if = "Option::is_none")]
389    pub rank: Option<i64>,
390    /// Fields to remove from role object
391    #[serde(skip_serializing_if = "Option::is_none")]
392    pub remove: Option<Vec<FieldsRole>>,
393}
394
395/// Server role permission value
396#[derive(Serialize, Debug, Clone, Default)]
397pub struct SetServerRolePermissionData {
398    /// Allow / deny values for the role in this server.
399    pub permissions: Override,
400}
401
402/// Default server role permission value
403#[derive(Serialize, Debug, Clone, Default)]
404pub struct SetDefaultRolePermissionData {
405    /// Allow / deny values for the role in this server.
406    pub permissions: Override,
407}
408
409/// Members query options
410#[derive(Serialize, Debug, Clone, Default)]
411pub struct FetchMembersData {
412    /// Whether to exclude offline users
413    #[serde(skip_serializing_if = "if_false")]
414    pub exclude_offline: bool,
415}
416
417/// Member edit data
418#[derive(Serialize, Debug, Clone, Default)]
419pub struct EditMemberData {
420    /// Member nickname
421    #[serde(skip_serializing_if = "Option::is_none")]
422    pub nickname: Option<String>,
423    /// Attachment Id to set for avatar
424    #[serde(skip_serializing_if = "Option::is_none")]
425    pub avatar: Option<String>,
426    /// Array of role ids
427    #[serde(skip_serializing_if = "Option::is_none")]
428    pub roles: Option<Vec<String>>,
429    /// Timestamp this member is timed out until
430    #[serde(skip_serializing_if = "Option::is_none")]
431    pub timeout: Option<Timestamp>,
432    /// Fields to remove from channel object
433    #[serde(skip_serializing_if = "Option::is_none")]
434    pub remove: Option<Vec<FieldsMember>>,
435}
436
437/// Ban information
438#[derive(Serialize, Debug, Clone, Default)]
439pub struct BanUserData {
440    /// Ban reason
441    #[serde(skip_serializing_if = "Option::is_none")]
442    pub reason: Option<String>,
443}
444
445/// New account data
446#[derive(Serialize, Debug, Clone, Default)]
447pub struct CreateAccountData {
448    /// Valid email address
449    pub email: String,
450    /// Password
451    pub password: String,
452    /// Invite code
453    #[serde(skip_serializing_if = "Option::is_none")]
454    pub invite: Option<String>,
455    /// Captcha verification code
456    #[serde(skip_serializing_if = "Option::is_none")]
457    pub captcha: Option<String>,
458}
459
460/// Resend information
461#[derive(Serialize, Debug, Clone, Default)]
462pub struct ResendVerificationData {
463    /// Email associated with the account
464    pub email: String,
465    /// Captcha verification code
466    #[serde(skip_serializing_if = "Option::is_none")]
467    pub captcha: Option<String>,
468}
469
470/// Account deletion data
471#[derive(Serialize, Debug, Clone)]
472pub struct ConfirmAccountDeletionData {
473    /// Deletion token
474    pub token: String,
475}
476
477/// Change password data
478#[derive(Serialize, Debug, Clone)]
479pub struct ChangePasswordData {
480    /// New password
481    pub password: String,
482    /// Current password
483    pub current_password: String,
484}
485
486/// Change email data
487#[derive(Serialize, Debug, Clone)]
488pub struct ChangeEmailData {
489    /// Valid email address
490    pub email: String,
491    /// Current password
492    pub current_password: String,
493}
494
495/// Reset password information
496#[derive(Serialize, Debug, Clone)]
497pub struct SendPasswordResetData {
498    /// Email associated with the account
499    pub email: String,
500    /// Captcha verification code
501    #[serde(skip_serializing_if = "Option::is_none")]
502    pub captcha: Option<String>,
503}
504
505/// Password reset data
506#[derive(Serialize, Debug, Clone)]
507pub struct PasswordResetData {
508    /// Reset token
509    pub token: String,
510    /// New password
511    pub password: String,
512    /// Whether to logout all sessions
513    #[serde(default)]
514    pub remove_sessions: bool,
515}
516
517/// New user data
518#[derive(Serialize, Debug, Clone)]
519pub struct CompleteOnboardingData {
520    /// New username which will be used to identify the user on the platform
521    pub username: String,
522}
523
524/// Edit report data
525#[derive(Serialize, Debug, Clone)]
526pub struct EditReportData {
527    /// New report status
528    #[serde(skip_serializing_if = "Option::is_none")]
529    pub status: Option<ReportStatus>,
530    /// Report notes
531    #[serde(skip_serializing_if = "Option::is_none")]
532    pub notes: Option<String>,
533}
534
535/// Report data
536#[derive(Serialize, Debug, Clone)]
537pub struct ReportContentData {
538    /// Content being reported
539    pub content: ReportedContent,
540    /// Additional report description
541    #[serde(skip_serializing_if = "Option::is_none")]
542    pub additional_context: Option<String>,
543}
544
545/// New strike information
546#[derive(Serialize, Debug, Clone)]
547pub struct CreateStrikeData {
548    /// ID of reported user
549    pub user_id: String,
550
551    /// Attached reason
552    pub reason: String,
553}
554
555/// Strike information edit data
556#[derive(Serialize, Debug, Clone)]
557pub struct EditAccountStrikeData {
558    /// New attached reason
559    pub reason: String,
560}
561
562/// Login data
563#[derive(Serialize, Debug, Clone)]
564#[serde(untagged)]
565pub enum LoginData {
566    Email {
567        /// Email
568        email: String,
569        /// Password
570        password: String,
571        /// Friendly name used for the session
572        #[serde(skip_serializing_if = "Option::is_none")]
573        friendly_name: Option<String>,
574    },
575    MFA {
576        /// Unvalidated or authorised MFA ticket
577        ///
578        /// Used to resolve the correct account
579        mfa_ticket: String,
580        /// Valid MFA response
581        ///
582        /// This will take precedence over the `password` field where applicable
583        #[serde(skip_serializing_if = "Option::is_none")]
584        mfa_response: Option<MFAData>,
585        /// Friendly name used for the session
586        #[serde(skip_serializing_if = "Option::is_none")]
587        friendly_name: Option<String>,
588    },
589}
590
591/// Sessions clear data
592#[derive(Serialize, Debug, Clone, Default)]
593pub struct DeleteAllSessionsData {
594    #[serde(skip_serializing_if = "if_false")]
595    pub revoke_self: bool,
596}
597
598/// Session edit data
599#[derive(Serialize, Debug, Clone)]
600pub struct EditSessionData {
601    /// Session friendly name
602    pub friendly_name: String,
603}
604
605/// MFA ticket create data
606pub type CreateMFATicketData = MFAData;
607
608/// TOTP secret generate data
609pub type EnableTOTP2FAData = MFAData;
610
611/// Webhook create data
612#[derive(Serialize, Debug, Clone, Default)]
613pub struct CreateWebhookData {
614    /// Webhook name
615    pub name: String,
616    /// Avatar's attachment ID
617    #[serde(skip_serializing_if = "Option::is_none")]
618    pub avatar: Option<String>,
619}