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")]
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 {
15 pub recipient_id: PersonId,
16 pub auth: Sensitive<String>,
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,
26 pub auth: Sensitive<String>,
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,
36 pub auth: Sensitive<String>,
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,
46 pub auth: Sensitive<String>,
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 creator_id: Option<PersonId>,
59 pub auth: Sensitive<String>,
62 #[derive(Debug, Serialize, Deserialize, Clone)]
63 #[cfg_attr(feature = "full", derive(TS))]
64 #[cfg_attr(feature = "full", ts(export))]
65 /// The private messages response.
66 pub struct PrivateMessagesResponse {
67 pub private_messages: Vec<PrivateMessageView>,
70 #[derive(Debug, Serialize, Deserialize, Clone)]
71 #[cfg_attr(feature = "full", derive(TS))]
72 #[cfg_attr(feature = "full", ts(export))]
73 /// A single private message response.
74 pub struct PrivateMessageResponse {
75 pub private_message_view: PrivateMessageView,
78 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
79 #[cfg_attr(feature = "full", derive(TS))]
80 #[cfg_attr(feature = "full", ts(export))]
81 /// Create a report for a private message.
82 pub struct CreatePrivateMessageReport {
83 pub private_message_id: PrivateMessageId,
85 pub auth: Sensitive<String>,
88 #[derive(Debug, Serialize, Deserialize, Clone)]
89 #[cfg_attr(feature = "full", derive(TS))]
90 #[cfg_attr(feature = "full", ts(export))]
91 /// A private message report response.
92 pub struct PrivateMessageReportResponse {
93 pub private_message_report_view: PrivateMessageReportView,
96 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
97 #[cfg_attr(feature = "full", derive(TS))]
98 #[cfg_attr(feature = "full", ts(export))]
99 /// Resolve a private message report.
100 pub struct ResolvePrivateMessageReport {
101 pub report_id: PrivateMessageReportId,
103 pub auth: Sensitive<String>,
106 #[skip_serializing_none]
107 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
108 #[cfg_attr(feature = "full", derive(TS))]
109 #[cfg_attr(feature = "full", ts(export))]
110 /// List private message reports.
111 // TODO , perhaps GetReports should be a tagged enum list too.
112 pub struct ListPrivateMessageReports {
113 pub page: Option<i64>,
114 pub limit: Option<i64>,
115 /// Only shows the unresolved reports
116 pub unresolved_only: Option<bool>,
117 pub auth: Sensitive<String>,
120 #[derive(Debug, Serialize, Deserialize, Clone)]
121 #[cfg_attr(feature = "full", derive(TS))]
122 #[cfg_attr(feature = "full", ts(export))]
123 /// The response for list private message reports.
124 pub struct ListPrivateMessageReportsResponse {
125 pub private_message_reports: Vec<PrivateMessageReportView>,