2022-09-19 22:58:42 +00:00
|
|
|
use crate::sensitive::Sensitive;
|
|
|
|
use lemmy_db_schema::newtypes::{PersonId, PrivateMessageId, PrivateMessageReportId};
|
|
|
|
use lemmy_db_views::structs::{PrivateMessageReportView, PrivateMessageView};
|
|
|
|
use serde::{Deserialize, Serialize};
|
2023-04-26 04:26:10 +00:00
|
|
|
use serde_with::skip_serializing_none;
|
|
|
|
#[cfg(feature = "full")]
|
|
|
|
use ts_rs::TS;
|
2022-09-19 22:58:42 +00:00
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Create a private message.
|
2022-09-19 22:58:42 +00:00
|
|
|
pub struct CreatePrivateMessage {
|
|
|
|
pub content: String,
|
|
|
|
pub recipient_id: PersonId,
|
|
|
|
pub auth: Sensitive<String>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Edit a private message.
|
2022-09-19 22:58:42 +00:00
|
|
|
pub struct EditPrivateMessage {
|
|
|
|
pub private_message_id: PrivateMessageId,
|
|
|
|
pub content: String,
|
|
|
|
pub auth: Sensitive<String>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Delete a private message.
|
2022-09-19 22:58:42 +00:00
|
|
|
pub struct DeletePrivateMessage {
|
|
|
|
pub private_message_id: PrivateMessageId,
|
|
|
|
pub deleted: bool,
|
|
|
|
pub auth: Sensitive<String>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Mark a private message as read.
|
2022-09-19 22:58:42 +00:00
|
|
|
pub struct MarkPrivateMessageAsRead {
|
|
|
|
pub private_message_id: PrivateMessageId,
|
|
|
|
pub read: bool,
|
|
|
|
pub auth: Sensitive<String>,
|
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2022-09-19 22:58:42 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Get your private messages.
|
2022-09-19 22:58:42 +00:00
|
|
|
pub struct GetPrivateMessages {
|
|
|
|
pub unread_only: Option<bool>,
|
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
2023-08-08 09:07:41 +00:00
|
|
|
pub creator_id: Option<PersonId>,
|
2022-09-19 22:58:42 +00:00
|
|
|
pub auth: Sensitive<String>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The private messages response.
|
2022-09-19 22:58:42 +00:00
|
|
|
pub struct PrivateMessagesResponse {
|
|
|
|
pub private_messages: Vec<PrivateMessageView>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A single private message response.
|
2022-09-19 22:58:42 +00:00
|
|
|
pub struct PrivateMessageResponse {
|
|
|
|
pub private_message_view: PrivateMessageView,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Create a report for a private message.
|
2022-09-19 22:58:42 +00:00
|
|
|
pub struct CreatePrivateMessageReport {
|
|
|
|
pub private_message_id: PrivateMessageId,
|
|
|
|
pub reason: String,
|
|
|
|
pub auth: Sensitive<String>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A private message report response.
|
2022-09-19 22:58:42 +00:00
|
|
|
pub struct PrivateMessageReportResponse {
|
|
|
|
pub private_message_report_view: PrivateMessageReportView,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Resolve a private message report.
|
2022-09-19 22:58:42 +00:00
|
|
|
pub struct ResolvePrivateMessageReport {
|
|
|
|
pub report_id: PrivateMessageReportId,
|
|
|
|
pub resolved: bool,
|
|
|
|
pub auth: Sensitive<String>,
|
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2022-09-19 22:58:42 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// List private message reports.
|
|
|
|
// TODO , perhaps GetReports should be a tagged enum list too.
|
2022-09-19 22:58:42 +00:00
|
|
|
pub struct ListPrivateMessageReports {
|
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
|
|
|
/// Only shows the unresolved reports
|
|
|
|
pub unresolved_only: Option<bool>,
|
|
|
|
pub auth: Sensitive<String>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The response for list private message reports.
|
2022-09-19 22:58:42 +00:00
|
|
|
pub struct ListPrivateMessageReportsResponse {
|
|
|
|
pub private_message_reports: Vec<PrivateMessageReportView>,
|
|
|
|
}
|