forked from
tranquil.farm/tranquil-pds
Our Personal Data Server from scratch!
1use uuid::Uuid;
2
3pub use tranquil_db_traits::{CommsChannel, CommsStatus, CommsType, QueuedComms};
4
5pub struct NewComms {
6 pub user_id: Uuid,
7 pub channel: CommsChannel,
8 pub comms_type: CommsType,
9 pub recipient: String,
10 pub subject: Option<String>,
11 pub body: String,
12 pub metadata: Option<serde_json::Value>,
13}
14
15impl NewComms {
16 pub fn new(
17 user_id: Uuid,
18 channel: CommsChannel,
19 comms_type: CommsType,
20 recipient: String,
21 subject: Option<String>,
22 body: String,
23 ) -> Self {
24 Self {
25 user_id,
26 channel,
27 comms_type,
28 recipient,
29 subject,
30 body,
31 metadata: None,
32 }
33 }
34
35 pub fn email(
36 user_id: Uuid,
37 comms_type: CommsType,
38 recipient: String,
39 subject: String,
40 body: String,
41 ) -> Self {
42 Self::new(
43 user_id,
44 CommsChannel::Email,
45 comms_type,
46 recipient,
47 Some(subject),
48 body,
49 )
50 }
51}