]> Untitled Git - lemmy.git/blobdiff - crates/api_common/src/person.rs
Adding diesel enums for SortType and ListingType (#2808)
[lemmy.git] / crates / api_common / src / person.rs
index 79e3041d8e8c8ab8ca0147b2bb52b6ae0eab442e..10a0e806f7f3003df143849ab90885a0626dcc28 100644 (file)
@@ -1,10 +1,16 @@
 use crate::sensitive::Sensitive;
-use lemmy_db_views::structs::{CommentView, PostView, PrivateMessageView};
+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,
-  PersonViewSafe,
+  PersonView,
 };
 use serde::{Deserialize, Serialize};
 
@@ -12,19 +18,8 @@ use serde::{Deserialize, Serialize};
 pub struct Login {
   pub username_or_email: Sensitive<String>,
   pub password: Sensitive<String>,
+  pub totp_2fa_token: Option<String>,
 }
-use lemmy_db_schema::{
-  newtypes::{
-    CommentReplyId,
-    CommunityId,
-    LanguageId,
-    PersonId,
-    PersonMentionId,
-    PrivateMessageId,
-  },
-  CommentSortType,
-  SortType,
-};
 
 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
 pub struct Register {
@@ -61,8 +56,8 @@ pub struct SaveUserSettings {
   pub show_nsfw: Option<bool>,
   pub show_scores: Option<bool>,
   pub theme: Option<String>,
-  pub default_sort_type: Option<i16>,
-  pub default_listing_type: Option<i16>,
+  pub default_sort_type: Option<SortType>,
+  pub default_listing_type: Option<ListingType>,
   pub interface_language: Option<String>,
   pub avatar: Option<String>,
   pub banner: Option<String>,
@@ -77,6 +72,8 @@ pub struct SaveUserSettings {
   pub show_read_posts: Option<bool>,
   pub show_new_post_notifs: Option<bool>,
   pub discussion_languages: Option<Vec<LanguageId>>,
+  /// None leaves it as is, true will generate or regenerate it, false clears it out
+  pub generate_totp_2fa: Option<bool>,
   pub auth: Sensitive<String>,
 }
 
@@ -111,7 +108,7 @@ pub struct GetPersonDetails {
 
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct GetPersonDetailsResponse {
-  pub person_view: PersonViewSafe,
+  pub person_view: PersonView,
   pub comments: Vec<CommentView>,
   pub posts: Vec<PostView>,
   pub moderates: Vec<CommunityModeratorView>,
@@ -141,7 +138,7 @@ pub struct AddAdmin {
 
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct AddAdminResponse {
-  pub admins: Vec<PersonViewSafe>,
+  pub admins: Vec<PersonView>,
 }
 
 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
@@ -161,12 +158,12 @@ pub struct GetBannedPersons {
 
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct BannedPersonsResponse {
-  pub banned: Vec<PersonViewSafe>,
+  pub banned: Vec<PersonView>,
 }
 
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct BanPersonResponse {
-  pub person_view: PersonViewSafe,
+  pub person_view: PersonView,
   pub banned: bool,
 }
 
@@ -179,7 +176,7 @@ pub struct BlockPerson {
 
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct BlockPersonResponse {
-  pub person_view: PersonViewSafe,
+  pub person_view: PersonView,
   pub blocked: bool,
 }
 
@@ -249,52 +246,6 @@ pub struct PasswordChangeAfterReset {
   pub password_verify: Sensitive<String>,
 }
 
-#[derive(Debug, Serialize, Deserialize, Clone, Default)]
-pub struct CreatePrivateMessage {
-  pub content: String,
-  pub recipient_id: PersonId,
-  pub auth: Sensitive<String>,
-}
-
-#[derive(Debug, Serialize, Deserialize, Clone, Default)]
-pub struct EditPrivateMessage {
-  pub private_message_id: PrivateMessageId,
-  pub content: String,
-  pub auth: Sensitive<String>,
-}
-
-#[derive(Debug, Serialize, Deserialize, Clone, Default)]
-pub struct DeletePrivateMessage {
-  pub private_message_id: PrivateMessageId,
-  pub deleted: bool,
-  pub auth: Sensitive<String>,
-}
-
-#[derive(Debug, Serialize, Deserialize, Clone, Default)]
-pub struct MarkPrivateMessageAsRead {
-  pub private_message_id: PrivateMessageId,
-  pub read: bool,
-  pub auth: Sensitive<String>,
-}
-
-#[derive(Debug, Serialize, Deserialize, Clone, Default)]
-pub struct GetPrivateMessages {
-  pub unread_only: Option<bool>,
-  pub page: Option<i64>,
-  pub limit: Option<i64>,
-  pub auth: Sensitive<String>,
-}
-
-#[derive(Debug, Serialize, Deserialize, Clone)]
-pub struct PrivateMessagesResponse {
-  pub private_messages: Vec<PrivateMessageView>,
-}
-
-#[derive(Debug, Serialize, Deserialize, Clone)]
-pub struct PrivateMessageResponse {
-  pub private_message_view: PrivateMessageView,
-}
-
 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
 pub struct GetReportCount {
   pub community_id: Option<CommunityId>,
@@ -306,6 +257,7 @@ pub struct GetReportCountResponse {
   pub community_id: Option<CommunityId>,
   pub comment_reports: i64,
   pub post_reports: i64,
+  pub private_message_reports: Option<i64>,
 }
 
 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
@@ -320,7 +272,7 @@ pub struct GetUnreadCountResponse {
   pub private_messages: i64,
 }
 
-#[derive(Serialize, Deserialize, Clone, Default)]
+#[derive(Serialize, Deserialize, Clone, Default, Debug)]
 pub struct VerifyEmail {
   pub token: String,
 }