]> Untitled Git - lemmy.git/blobdiff - crates/db_views/src/structs.rs
Add Custom Emojis Support (#2616)
[lemmy.git] / crates / db_views / src / structs.rs
index 59a5f0fe3d771c7444d27998ced1aa5d5eac1c3f..b3b2b1c7a51b942c3fbddfff982afe8c6f24406f 100644 (file)
@@ -3,42 +3,47 @@ use lemmy_db_schema::{
   source::{
     comment::Comment,
     comment_report::CommentReport,
-    community::CommunitySafe,
-    local_user::{LocalUser, LocalUserSettings},
-    person::{Person, PersonSafe, PersonSafeAlias1, PersonSafeAlias2},
+    community::Community,
+    custom_emoji::CustomEmoji,
+    custom_emoji_keyword::CustomEmojiKeyword,
+    local_site::LocalSite,
+    local_site_rate_limit::LocalSiteRateLimit,
+    local_user::LocalUser,
+    person::Person,
     post::Post,
     post_report::PostReport,
     private_message::PrivateMessage,
+    private_message_report::PrivateMessageReport,
     registration_application::RegistrationApplication,
     site::Site,
   },
+  SubscribedType,
 };
 use serde::{Deserialize, Serialize};
 
-#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
+#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
 pub struct CommentReportView {
   pub comment_report: CommentReport,
   pub comment: Comment,
   pub post: Post,
-  pub community: CommunitySafe,
-  pub creator: PersonSafe,
-  pub comment_creator: PersonSafeAlias1,
+  pub community: Community,
+  pub creator: Person,
+  pub comment_creator: Person,
   pub counts: CommentAggregates,
   pub creator_banned_from_community: bool, // Left Join to CommunityPersonBan
   pub my_vote: Option<i16>,                // Left join to CommentLike
-  pub resolver: Option<PersonSafeAlias2>,
+  pub resolver: Option<Person>,
 }
 
-#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
+#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
 pub struct CommentView {
   pub comment: Comment,
-  pub creator: PersonSafe,
-  pub recipient: Option<PersonSafeAlias1>, // Left joins to comment and person
+  pub creator: Person,
   pub post: Post,
-  pub community: CommunitySafe,
+  pub community: Community,
   pub counts: CommentAggregates,
   pub creator_banned_from_community: bool, // Left Join to CommunityPersonBan
-  pub subscribed: bool,                    // Left join to CommunityFollower
+  pub subscribed: SubscribedType,          // Left join to CommunityFollower
   pub saved: bool,                         // Left join to CommentSaved
   pub creator_blocked: bool,               // Left join to PersonBlock
   pub my_vote: Option<i16>,                // Left join to CommentLike
@@ -51,57 +56,67 @@ pub struct LocalUserView {
   pub counts: PersonAggregates,
 }
 
-#[derive(Debug, Serialize, Deserialize, Clone)]
-pub struct LocalUserSettingsView {
-  pub local_user: LocalUserSettings,
-  pub person: PersonSafe,
-  pub counts: PersonAggregates,
-}
-
-#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
+#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
 pub struct PostReportView {
   pub post_report: PostReport,
   pub post: Post,
-  pub community: CommunitySafe,
-  pub creator: PersonSafe,
-  pub post_creator: PersonSafeAlias1,
+  pub community: Community,
+  pub creator: Person,
+  pub post_creator: Person,
   pub creator_banned_from_community: bool,
   pub my_vote: Option<i16>,
   pub counts: PostAggregates,
-  pub resolver: Option<PersonSafeAlias2>,
+  pub resolver: Option<Person>,
 }
 
-#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
+#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
 pub struct PostView {
   pub post: Post,
-  pub creator: PersonSafe,
-  pub community: CommunitySafe,
+  pub creator: Person,
+  pub community: Community,
   pub creator_banned_from_community: bool, // Left Join to CommunityPersonBan
   pub counts: PostAggregates,
-  pub subscribed: bool,      // Left join to CommunityFollower
-  pub saved: bool,           // Left join to PostSaved
-  pub read: bool,            // Left join to PostRead
-  pub creator_blocked: bool, // Left join to PersonBlock
-  pub my_vote: Option<i16>,  // Left join to PostLike
+  pub subscribed: SubscribedType, // Left join to CommunityFollower
+  pub saved: bool,                // Left join to PostSaved
+  pub read: bool,                 // Left join to PostRead
+  pub creator_blocked: bool,      // Left join to PersonBlock
+  pub my_vote: Option<i16>,       // Left join to PostLike
+  pub unread_comments: i64,       // Left join to PersonPostAggregates
 }
 
-#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
+#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
 pub struct PrivateMessageView {
   pub private_message: PrivateMessage,
-  pub creator: PersonSafe,
-  pub recipient: PersonSafeAlias1,
+  pub creator: Person,
+  pub recipient: Person,
 }
 
-#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
+#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
+pub struct PrivateMessageReportView {
+  pub private_message_report: PrivateMessageReport,
+  pub private_message: PrivateMessage,
+  pub private_message_creator: Person,
+  pub creator: Person,
+  pub resolver: Option<Person>,
+}
+
+#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
 pub struct RegistrationApplicationView {
   pub registration_application: RegistrationApplication,
-  pub creator_local_user: LocalUserSettings,
-  pub creator: PersonSafe,
-  pub admin: Option<PersonSafeAlias1>,
+  pub creator_local_user: LocalUser,
+  pub creator: Person,
+  pub admin: Option<Person>,
 }
 
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct SiteView {
   pub site: Site,
+  pub local_site: LocalSite,
+  pub local_site_rate_limit: LocalSiteRateLimit,
   pub counts: SiteAggregates,
 }
+#[derive(Debug, Serialize, Deserialize, Clone)]
+pub struct CustomEmojiView {
+  pub custom_emoji: CustomEmoji,
+  pub keywords: Vec<CustomEmojiKeyword>,
+}