]> Untitled Git - lemmy.git/blobdiff - crates/db_views_moderator/src/structs.rs
Add Modlog Filters (#2313)
[lemmy.git] / crates / db_views_moderator / src / structs.rs
index ebe93399c0063aba7cdb9c61d79ab15ba220a931..4f6fbbd3ea0125c8d0c86f2ba95b574372e3236d 100644 (file)
@@ -1,32 +1,35 @@
-use lemmy_db_schema::source::{
-  comment::Comment,
-  community::CommunitySafe,
-  moderator::{
-    AdminPurgeComment,
-    AdminPurgeCommunity,
-    AdminPurgePerson,
-    AdminPurgePost,
-    ModAdd,
-    ModAddCommunity,
-    ModBan,
-    ModBanFromCommunity,
-    ModHideCommunity,
-    ModLockPost,
-    ModRemoveComment,
-    ModRemoveCommunity,
-    ModRemovePost,
-    ModStickyPost,
-    ModTransferCommunity,
+use lemmy_db_schema::{
+  newtypes::{CommunityId, PersonId},
+  source::{
+    comment::Comment,
+    community::CommunitySafe,
+    moderator::{
+      AdminPurgeComment,
+      AdminPurgeCommunity,
+      AdminPurgePerson,
+      AdminPurgePost,
+      ModAdd,
+      ModAddCommunity,
+      ModBan,
+      ModBanFromCommunity,
+      ModHideCommunity,
+      ModLockPost,
+      ModRemoveComment,
+      ModRemoveCommunity,
+      ModRemovePost,
+      ModStickyPost,
+      ModTransferCommunity,
+    },
+    person::{PersonSafe, PersonSafeAlias1},
+    post::Post,
   },
-  person::{PersonSafe, PersonSafeAlias1},
-  post::Post,
 };
 use serde::{Deserialize, Serialize};
 
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct ModAddCommunityView {
   pub mod_add_community: ModAddCommunity,
-  pub moderator: PersonSafe,
+  pub moderator: Option<PersonSafe>,
   pub community: CommunitySafe,
   pub modded_person: PersonSafeAlias1,
 }
@@ -34,14 +37,14 @@ pub struct ModAddCommunityView {
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct ModAddView {
   pub mod_add: ModAdd,
-  pub moderator: PersonSafe,
+  pub moderator: Option<PersonSafe>,
   pub modded_person: PersonSafeAlias1,
 }
 
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct ModBanFromCommunityView {
   pub mod_ban_from_community: ModBanFromCommunity,
-  pub moderator: PersonSafe,
+  pub moderator: Option<PersonSafe>,
   pub community: CommunitySafe,
   pub banned_person: PersonSafeAlias1,
 }
@@ -49,21 +52,21 @@ pub struct ModBanFromCommunityView {
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct ModBanView {
   pub mod_ban: ModBan,
-  pub moderator: PersonSafe,
+  pub moderator: Option<PersonSafe>,
   pub banned_person: PersonSafeAlias1,
 }
 
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct ModHideCommunityView {
   pub mod_hide_community: ModHideCommunity,
-  pub admin: PersonSafe,
+  pub admin: Option<PersonSafe>,
   pub community: CommunitySafe,
 }
 
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct ModLockPostView {
   pub mod_lock_post: ModLockPost,
-  pub moderator: PersonSafe,
+  pub moderator: Option<PersonSafe>,
   pub post: Post,
   pub community: CommunitySafe,
 }
@@ -71,7 +74,7 @@ pub struct ModLockPostView {
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct ModRemoveCommentView {
   pub mod_remove_comment: ModRemoveComment,
-  pub moderator: PersonSafe,
+  pub moderator: Option<PersonSafe>,
   pub comment: Comment,
   pub commenter: PersonSafeAlias1,
   pub post: Post,
@@ -81,14 +84,14 @@ pub struct ModRemoveCommentView {
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct ModRemoveCommunityView {
   pub mod_remove_community: ModRemoveCommunity,
-  pub moderator: PersonSafe,
+  pub moderator: Option<PersonSafe>,
   pub community: CommunitySafe,
 }
 
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct ModRemovePostView {
   pub mod_remove_post: ModRemovePost,
-  pub moderator: PersonSafe,
+  pub moderator: Option<PersonSafe>,
   pub post: Post,
   pub community: CommunitySafe,
 }
@@ -96,7 +99,7 @@ pub struct ModRemovePostView {
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct ModStickyPostView {
   pub mod_sticky_post: ModStickyPost,
-  pub moderator: PersonSafe,
+  pub moderator: Option<PersonSafe>,
   pub post: Post,
   pub community: CommunitySafe,
 }
@@ -104,7 +107,7 @@ pub struct ModStickyPostView {
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct ModTransferCommunityView {
   pub mod_transfer_community: ModTransferCommunity,
-  pub moderator: PersonSafe,
+  pub moderator: Option<PersonSafe>,
   pub community: CommunitySafe,
   pub modded_person: PersonSafeAlias1,
 }
@@ -112,25 +115,35 @@ pub struct ModTransferCommunityView {
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct AdminPurgeCommentView {
   pub admin_purge_comment: AdminPurgeComment,
-  pub admin: PersonSafe,
+  pub admin: Option<PersonSafe>,
   pub post: Post,
 }
 
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct AdminPurgeCommunityView {
   pub admin_purge_community: AdminPurgeCommunity,
-  pub admin: PersonSafe,
+  pub admin: Option<PersonSafe>,
 }
 
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct AdminPurgePersonView {
   pub admin_purge_person: AdminPurgePerson,
-  pub admin: PersonSafe,
+  pub admin: Option<PersonSafe>,
 }
 
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub struct AdminPurgePostView {
   pub admin_purge_post: AdminPurgePost,
-  pub admin: PersonSafe,
+  pub admin: Option<PersonSafe>,
   pub community: CommunitySafe,
 }
+
+#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
+pub struct ModlogListParams {
+  pub community_id: Option<CommunityId>,
+  pub mod_person_id: Option<PersonId>,
+  pub other_person_id: Option<PersonId>,
+  pub page: Option<i64>,
+  pub limit: Option<i64>,
+  pub hide_modlog_names: bool,
+}