]> Untitled Git - lemmy.git/blob - crates/api_common/src/private_message.rs
Remove SendActivity and Perform traits, rely on channel (#3596)
[lemmy.git] / crates / api_common / src / private_message.rs
1 use crate::sensitive::Sensitive;
2 use lemmy_db_schema::newtypes::{PersonId, PrivateMessageId, PrivateMessageReportId};
3 use lemmy_db_views::structs::{PrivateMessageReportView, PrivateMessageView};
4 use serde::{Deserialize, Serialize};
5 use serde_with::skip_serializing_none;
6 #[cfg(feature = "full")]
7 use ts_rs::TS;
8
9 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
10 #[cfg_attr(feature = "full", derive(TS))]
11 #[cfg_attr(feature = "full", ts(export))]
12 /// Create a private message.
13 pub struct CreatePrivateMessage {
14   pub content: String,
15   pub recipient_id: PersonId,
16   pub auth: Sensitive<String>,
17 }
18
19 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
20 #[cfg_attr(feature = "full", derive(TS))]
21 #[cfg_attr(feature = "full", ts(export))]
22 /// Edit a private message.
23 pub struct EditPrivateMessage {
24   pub private_message_id: PrivateMessageId,
25   pub content: String,
26   pub auth: Sensitive<String>,
27 }
28
29 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
30 #[cfg_attr(feature = "full", derive(TS))]
31 #[cfg_attr(feature = "full", ts(export))]
32 /// Delete a private message.
33 pub struct DeletePrivateMessage {
34   pub private_message_id: PrivateMessageId,
35   pub deleted: bool,
36   pub auth: Sensitive<String>,
37 }
38
39 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
40 #[cfg_attr(feature = "full", derive(TS))]
41 #[cfg_attr(feature = "full", ts(export))]
42 /// Mark a private message as read.
43 pub struct MarkPrivateMessageAsRead {
44   pub private_message_id: PrivateMessageId,
45   pub read: bool,
46   pub auth: Sensitive<String>,
47 }
48
49 #[skip_serializing_none]
50 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
51 #[cfg_attr(feature = "full", derive(TS))]
52 #[cfg_attr(feature = "full", ts(export))]
53 /// Get your private messages.
54 pub struct GetPrivateMessages {
55   pub unread_only: Option<bool>,
56   pub page: Option<i64>,
57   pub limit: Option<i64>,
58   pub auth: Sensitive<String>,
59 }
60
61 #[derive(Debug, Serialize, Deserialize, Clone)]
62 #[cfg_attr(feature = "full", derive(TS))]
63 #[cfg_attr(feature = "full", ts(export))]
64 /// The private messages response.
65 pub struct PrivateMessagesResponse {
66   pub private_messages: Vec<PrivateMessageView>,
67 }
68
69 #[derive(Debug, Serialize, Deserialize, Clone)]
70 #[cfg_attr(feature = "full", derive(TS))]
71 #[cfg_attr(feature = "full", ts(export))]
72 /// A single private message response.
73 pub struct PrivateMessageResponse {
74   pub private_message_view: PrivateMessageView,
75 }
76
77 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
78 #[cfg_attr(feature = "full", derive(TS))]
79 #[cfg_attr(feature = "full", ts(export))]
80 /// Create a report for a private message.
81 pub struct CreatePrivateMessageReport {
82   pub private_message_id: PrivateMessageId,
83   pub reason: String,
84   pub auth: Sensitive<String>,
85 }
86
87 #[derive(Debug, Serialize, Deserialize, Clone)]
88 #[cfg_attr(feature = "full", derive(TS))]
89 #[cfg_attr(feature = "full", ts(export))]
90 /// A private message report response.
91 pub struct PrivateMessageReportResponse {
92   pub private_message_report_view: PrivateMessageReportView,
93 }
94
95 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
96 #[cfg_attr(feature = "full", derive(TS))]
97 #[cfg_attr(feature = "full", ts(export))]
98 /// Resolve a private message report.
99 pub struct ResolvePrivateMessageReport {
100   pub report_id: PrivateMessageReportId,
101   pub resolved: bool,
102   pub auth: Sensitive<String>,
103 }
104
105 #[skip_serializing_none]
106 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
107 #[cfg_attr(feature = "full", derive(TS))]
108 #[cfg_attr(feature = "full", ts(export))]
109 /// List private message reports.
110 // TODO , perhaps GetReports should be a tagged enum list too.
111 pub struct ListPrivateMessageReports {
112   pub page: Option<i64>,
113   pub limit: Option<i64>,
114   /// Only shows the unresolved reports
115   pub unresolved_only: Option<bool>,
116   pub auth: Sensitive<String>,
117 }
118
119 #[derive(Debug, Serialize, Deserialize, Clone)]
120 #[cfg_attr(feature = "full", derive(TS))]
121 #[cfg_attr(feature = "full", ts(export))]
122 /// The response for list private message reports.
123 pub struct ListPrivateMessageReportsResponse {
124   pub private_message_reports: Vec<PrivateMessageReportView>,
125 }