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

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ThreePidRecord {
    session_id: String,
    passphrase: OwnedClientSecret,
}

impl ThreePidRecord {
    pub fn new(session_id: String, passphrase: OwnedClientSecret) -> Self {
        ThreePidRecord {
            session_id,
            passphrase,
        }
    }

    pub fn session_id(&self) -> String {
        self.session_id.clone()
    }

    pub fn passphrase(&self) -> OwnedClientSecret {
        self.passphrase.clone()
    }
}

#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[ruma_event(type = "global.acter.dev.three_pid", kind = GlobalAccountData)]
pub struct ThreePidContent {
    pub via_email: BTreeMap<String, ThreePidRecord>,
    pub via_phone: BTreeMap<String, ThreePidRecord>,
}