polyphony_types/entities/
user_settings.rs

1use chrono::{serde::ts_milliseconds_option, Utc};
2use serde::{Deserialize, Serialize};
3
4use crate::utils::Snowflake;
5
6#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
7#[serde(rename_all = "lowercase")]
8pub enum UserStatus {
9    #[default]
10    Online,
11    Offline,
12    Dnd,
13    Idle,
14    Invisible,
15}
16
17#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
18#[serde(rename_all = "lowercase")]
19pub enum UserTheme {
20    #[default]
21    Dark,
22    Light,
23}
24
25#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
26pub struct UserSettings {
27    pub id: String,
28    pub afk_timeout: u16,
29    pub allow_accessibility_detection: bool,
30    pub animate_emoji: bool,
31    pub animate_stickers: u8,
32    pub contact_sync_enabled: bool,
33    pub convert_emoticons: bool,
34    pub custom_status: Option<CustomStatus>,
35    pub default_guilds_restricted: bool,
36    pub detect_platform_accounts: bool,
37    pub developer_mode: bool,
38    pub disable_games_tab: bool,
39    pub enable_tts_command: bool,
40    pub explicit_content_filter: u8,
41    pub friend_source_flags: FriendSourceFlags,
42    pub gateway_connected: bool,
43    pub gif_auto_play: bool,
44    pub guild_folders: Vec<GuildFolder>,
45    pub guild_positions: Vec<String>,
46    pub inline_attachment_media: bool,
47    pub inline_embed_media: bool,
48    pub locale: String,
49    pub message_display_compact: bool,
50    pub native_phone_integration_enabled: bool,
51    pub render_embeds: bool,
52    pub render_reactions: bool,
53    pub restricted_guilds: Vec<String>,
54    pub show_current_game: bool,
55    pub status: UserStatus,
56    pub stream_notifications_enabled: bool,
57    pub theme: UserTheme,
58    pub timezone_offset: i16,
59}
60
61impl Default for UserSettings {
62    fn default() -> Self {
63        Self {
64            id: Snowflake::generate().to_string(),
65            afk_timeout: 3600,
66            allow_accessibility_detection: true,
67            animate_emoji: true,
68            animate_stickers: 0,
69            contact_sync_enabled: false,
70            convert_emoticons: false,
71            custom_status: None,
72            default_guilds_restricted: false,
73            detect_platform_accounts: false,
74            developer_mode: true,
75            disable_games_tab: true,
76            enable_tts_command: false,
77            explicit_content_filter: 0,
78            friend_source_flags: FriendSourceFlags::default(),
79            gateway_connected: false,
80            gif_auto_play: false,
81            guild_folders: Vec::new(),
82            guild_positions: Vec::new(),
83            inline_attachment_media: true,
84            inline_embed_media: true,
85            locale: "en-US".to_string(),
86            message_display_compact: false,
87            native_phone_integration_enabled: true,
88            render_embeds: true,
89            render_reactions: true,
90            restricted_guilds: Vec::new(),
91            show_current_game: true,
92            status: UserStatus::Online,
93            stream_notifications_enabled: false,
94            theme: UserTheme::Dark,
95            timezone_offset: 0,
96        }
97    }
98}
99
100#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
101pub struct CustomStatus {
102    pub emoji_id: Option<String>,
103    pub emoji_name: Option<String>,
104    #[serde(with = "ts_milliseconds_option")]
105    pub expires_at: Option<chrono::DateTime<Utc>>,
106    pub text: Option<String>,
107}
108
109#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
110pub struct FriendSourceFlags {
111    pub all: bool,
112}
113
114impl Default for FriendSourceFlags {
115    fn default() -> Self {
116        Self { all: true }
117    }
118}
119
120#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
121pub struct GuildFolder {
122    pub color: u32,
123    pub guild_ids: Vec<String>,
124    pub id: u16,
125    pub name: String,
126}
127
128#[derive(Debug, Serialize, Deserialize)]
129pub struct LoginResult {
130    pub token: String,
131    pub settings: UserSettings,
132}