Nutomic
f858d8cbce
* Remove explicit auth params (ref #3725) Only take auth via header or cookie. This requires a new version of lemmy-js-client for api tests to pass. * rework api_crud * remove remaining auth params, move logic to session middleware * fmt, fix test * update js client * remove auth param from api tests * Pass auth as header * add ! * url vars, setHeader * cleanup * fmt * update * Updating for new lemmy-js-client. --------- Co-authored-by: Dessalines <tyhou13@gmx.com> Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
117 lines
3.7 KiB
Rust
117 lines
3.7 KiB
Rust
use lemmy_db_schema::newtypes::{PersonId, PrivateMessageId, PrivateMessageReportId};
|
|
use lemmy_db_views::structs::{PrivateMessageReportView, PrivateMessageView};
|
|
use serde::{Deserialize, Serialize};
|
|
use serde_with::skip_serializing_none;
|
|
#[cfg(feature = "full")]
|
|
use ts_rs::TS;
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// Create a private message.
|
|
pub struct CreatePrivateMessage {
|
|
pub content: String,
|
|
pub recipient_id: PersonId,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// Edit a private message.
|
|
pub struct EditPrivateMessage {
|
|
pub private_message_id: PrivateMessageId,
|
|
pub content: String,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// Delete a private message.
|
|
pub struct DeletePrivateMessage {
|
|
pub private_message_id: PrivateMessageId,
|
|
pub deleted: bool,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// Mark a private message as read.
|
|
pub struct MarkPrivateMessageAsRead {
|
|
pub private_message_id: PrivateMessageId,
|
|
pub read: bool,
|
|
}
|
|
|
|
#[skip_serializing_none]
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// Get your private messages.
|
|
pub struct GetPrivateMessages {
|
|
pub unread_only: Option<bool>,
|
|
pub page: Option<i64>,
|
|
pub limit: Option<i64>,
|
|
pub creator_id: Option<PersonId>,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// The private messages response.
|
|
pub struct PrivateMessagesResponse {
|
|
pub private_messages: Vec<PrivateMessageView>,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// A single private message response.
|
|
pub struct PrivateMessageResponse {
|
|
pub private_message_view: PrivateMessageView,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// Create a report for a private message.
|
|
pub struct CreatePrivateMessageReport {
|
|
pub private_message_id: PrivateMessageId,
|
|
pub reason: String,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// A private message report response.
|
|
pub struct PrivateMessageReportResponse {
|
|
pub private_message_report_view: PrivateMessageReportView,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// Resolve a private message report.
|
|
pub struct ResolvePrivateMessageReport {
|
|
pub report_id: PrivateMessageReportId,
|
|
pub resolved: bool,
|
|
}
|
|
|
|
#[skip_serializing_none]
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// List private message reports.
|
|
// TODO , perhaps GetReports should be a tagged enum list too.
|
|
pub struct ListPrivateMessageReports {
|
|
pub page: Option<i64>,
|
|
pub limit: Option<i64>,
|
|
/// Only shows the unresolved reports
|
|
pub unresolved_only: Option<bool>,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// The response for list private message reports.
|
|
pub struct ListPrivateMessageReportsResponse {
|
|
pub private_message_reports: Vec<PrivateMessageReportView>,
|
|
}
|