acter_core/events/
room.rs

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
use matrix_sdk_base::ruma::events::macros::EventContent;
use serde::{Deserialize, Serialize};

pub static USER_SETTINGS_KEY: &str = "global.acter.user_settings";

struct BoolDefaults();

impl BoolDefaults {
    const fn default_true() -> bool {
        true
    }

    const fn default_false() -> bool {
        false
    }

    const fn is_true(value: &bool) -> bool {
        *value
    }

    const fn is_false(value: &bool) -> bool {
        !(*value)
    }
}
#[derive(Debug, Serialize, Deserialize, Clone, EventContent)]
#[ruma_event(type = "global.acter.user_settings", kind = RoomAccountData)]
pub struct UserSettingsEventContent {
    #[serde(
        default = "BoolDefaults::default_false",
        skip_serializing_if = "BoolDefaults::is_false"
    )]
    pub has_seen_suggested: bool,

    #[serde(
        default = "BoolDefaults::default_true",
        skip_serializing_if = "BoolDefaults::is_true"
    )]
    pub include_cal_sync: bool,
}

impl Default for UserSettingsEventContent {
    fn default() -> Self {
        Self {
            has_seen_suggested: false,
            include_cal_sync: true,
        }
    }
}