robespierre_models/
invites.rs1use serde::{Deserialize, Serialize};
2
3use crate::{
4 autumn::Attachment,
5 id::{ChannelId, InviteId, ServerId, UserId},
6};
7
8#[derive(Serialize, Deserialize, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
11#[serde(deny_unknown_fields)]
12pub struct ServerInvite {
13 #[serde(rename = "_id")]
14 pub id: InviteId,
15 pub server: ServerId,
16 pub creator: UserId,
17 pub channel: ChannelId,
19}
20
21#[derive(Serialize, Deserialize, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
24#[serde(tag = "type")]
25#[serde(deny_unknown_fields)]
26pub enum Invite {
27 Invite(ServerInvite),
28}
29
30#[derive(Serialize, Deserialize, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
33#[serde(deny_unknown_fields)]
34pub struct ServerRetrievedInvite {
35 pub server_id: ServerId,
36 pub server_name: String,
37 #[serde(default, skip_serializing_if = "Option::is_none")]
38 pub server_icon: Option<Attachment>,
39 #[serde(default, skip_serializing_if = "Option::is_none")]
40 pub server_banner: Option<Attachment>,
41 pub channel_id: ChannelId,
42 pub channel_name: String,
43 #[serde(default, skip_serializing_if = "Option::is_none")]
44 pub channel_description: Option<String>,
45 pub user_name: String,
46 #[serde(default, skip_serializing_if = "Option::is_none")]
47 pub user_avatar: Option<Attachment>,
48 pub member_count: usize,
49}
50
51#[derive(Serialize, Deserialize, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
52#[serde(tag = "type")]
53#[serde(deny_unknown_fields)]
54pub enum RetrievedInvite {
55 Server(ServerRetrievedInvite),
56}