use crate::sensitive::Sensitive; use lemmy_db_schema::{ newtypes::{CommentReplyId, CommunityId, LanguageId, PersonId, PersonMentionId}, CommentSortType, ListingType, SortType, }; use lemmy_db_views::structs::{CommentView, PostView}; use lemmy_db_views_actor::structs::{ CommentReplyView, CommunityModeratorView, PersonMentionView, PersonView, }; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; #[cfg(feature = "full")] use ts_rs::TS; #[skip_serializing_none] #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct Login { pub username_or_email: Sensitive, pub password: Sensitive, pub totp_2fa_token: Option, } #[skip_serializing_none] #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct Register { pub username: String, pub password: Sensitive, pub password_verify: Sensitive, pub show_nsfw: bool, /// email is mandatory if email verification is enabled on the server pub email: Option>, pub captcha_uuid: Option, pub captcha_answer: Option, pub honeypot: Option, /// An answer is mandatory if require application is enabled on the server pub answer: Option, } #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct GetCaptcha {} #[skip_serializing_none] #[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct GetCaptchaResponse { pub ok: Option, // Will be None if captchas are disabled } #[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct CaptchaResponse { /// A Base64 encoded png pub png: String, /// A Base64 encoded wav audio pub wav: String, pub uuid: String, } #[skip_serializing_none] #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct SaveUserSettings { pub show_nsfw: Option, pub show_scores: Option, pub theme: Option, pub default_sort_type: Option, pub default_listing_type: Option, pub interface_language: Option, pub avatar: Option, pub banner: Option, pub display_name: Option, pub email: Option>, pub bio: Option, pub matrix_user_id: Option, pub show_avatars: Option, pub send_notifications_to_email: Option, pub bot_account: Option, pub show_bot_accounts: Option, pub show_read_posts: Option, pub show_new_post_notifs: Option, pub discussion_languages: Option>, /// None leaves it as is, true will generate or regenerate it, false clears it out pub generate_totp_2fa: Option, pub auth: Sensitive, } #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct ChangePassword { pub new_password: Sensitive, pub new_password_verify: Sensitive, pub old_password: Sensitive, pub auth: Sensitive, } #[skip_serializing_none] #[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct LoginResponse { /// This is None in response to `Register` if email verification is enabled, or the server requires registration applications. pub jwt: Option>, pub registration_created: bool, pub verify_email_sent: bool, } #[skip_serializing_none] #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct GetPersonDetails { pub person_id: Option, // One of these two are required /// Example: dessalines , or dessalines@xyz.tld pub username: Option, pub sort: Option, pub page: Option, pub limit: Option, pub community_id: Option, pub saved_only: Option, pub auth: Option>, } #[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct GetPersonDetailsResponse { pub person_view: PersonView, pub comments: Vec, pub posts: Vec, pub moderates: Vec, } #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct GetRepliesResponse { pub replies: Vec, } #[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct GetPersonMentionsResponse { pub mentions: Vec, } #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct MarkAllAsRead { pub auth: Sensitive, } #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct AddAdmin { pub person_id: PersonId, pub added: bool, pub auth: Sensitive, } #[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct AddAdminResponse { pub admins: Vec, } #[skip_serializing_none] #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct BanPerson { pub person_id: PersonId, pub ban: bool, pub remove_data: Option, pub reason: Option, pub expires: Option, pub auth: Sensitive, } #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct GetBannedPersons { pub auth: Sensitive, } #[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct BannedPersonsResponse { pub banned: Vec, } #[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct BanPersonResponse { pub person_view: PersonView, pub banned: bool, } #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct BlockPerson { pub person_id: PersonId, pub block: bool, pub auth: Sensitive, } #[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct BlockPersonResponse { pub person_view: PersonView, pub blocked: bool, } #[skip_serializing_none] #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct GetReplies { pub sort: Option, pub page: Option, pub limit: Option, pub unread_only: Option, pub auth: Sensitive, } #[skip_serializing_none] #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct GetPersonMentions { pub sort: Option, pub page: Option, pub limit: Option, pub unread_only: Option, pub auth: Sensitive, } #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct MarkPersonMentionAsRead { pub person_mention_id: PersonMentionId, pub read: bool, pub auth: Sensitive, } #[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct PersonMentionResponse { pub person_mention_view: PersonMentionView, } #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct MarkCommentReplyAsRead { pub comment_reply_id: CommentReplyId, pub read: bool, pub auth: Sensitive, } #[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct CommentReplyResponse { pub comment_reply_view: CommentReplyView, } #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct DeleteAccount { pub password: Sensitive, pub auth: Sensitive, } #[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct DeleteAccountResponse {} #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct PasswordReset { pub email: Sensitive, } #[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct PasswordResetResponse {} #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct PasswordChangeAfterReset { pub token: Sensitive, pub password: Sensitive, pub password_verify: Sensitive, } #[skip_serializing_none] #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct GetReportCount { pub community_id: Option, pub auth: Sensitive, } #[skip_serializing_none] #[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct GetReportCountResponse { pub community_id: Option, pub comment_reports: i64, pub post_reports: i64, pub private_message_reports: Option, } #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct GetUnreadCount { pub auth: Sensitive, } #[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct GetUnreadCountResponse { pub replies: i64, pub mentions: i64, pub private_messages: i64, } #[derive(Serialize, Deserialize, Clone, Default, Debug)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct VerifyEmail { pub token: String, } #[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] pub struct VerifyEmailResponse {}