mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-09-02 11:13:51 +00:00
Rename modlog items (#5882)
* Rename modlog items * wip: update schema * update code * move
This commit is contained in:
parent
c8ac7e02d5
commit
398237b02a
27 changed files with 736 additions and 701 deletions
|
@ -10,7 +10,7 @@ use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
community::{Community, CommunityActions, CommunityModeratorForm},
|
community::{Community, CommunityActions, CommunityModeratorForm},
|
||||||
local_user::LocalUser,
|
local_user::LocalUser,
|
||||||
mod_log::moderator::{ModAddCommunity, ModAddCommunityForm},
|
mod_log::moderator::{ModAddToCommunity, ModAddToCommunityForm},
|
||||||
},
|
},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
utils::get_conn,
|
utils::get_conn,
|
||||||
|
@ -68,14 +68,14 @@ pub async fn add_mod_to_community(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mod tables
|
// Mod tables
|
||||||
let form = ModAddCommunityForm {
|
let form = ModAddToCommunityForm {
|
||||||
mod_person_id: local_user_view.person.id,
|
mod_person_id: local_user_view.person.id,
|
||||||
other_person_id: tx_data.person_id,
|
other_person_id: tx_data.person_id,
|
||||||
community_id: tx_data.community_id,
|
community_id: tx_data.community_id,
|
||||||
removed: Some(!tx_data.added),
|
removed: Some(!tx_data.added),
|
||||||
};
|
};
|
||||||
|
|
||||||
ModAddCommunity::create(&mut conn.into(), &form).await?;
|
ModAddToCommunity::create(&mut conn.into(), &form).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ use lemmy_api_utils::{context::LemmyContext, utils::is_admin};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
local_user::{LocalUser, LocalUserUpdateForm},
|
local_user::{LocalUser, LocalUserUpdateForm},
|
||||||
mod_log::moderator::{ModAdd, ModAddForm},
|
mod_log::admin::{AdminAdd, AdminAddForm},
|
||||||
},
|
},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
};
|
};
|
||||||
|
@ -44,13 +44,13 @@ pub async fn add_admin(
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Mod tables
|
// Mod tables
|
||||||
let form = ModAddForm {
|
let form = AdminAddForm {
|
||||||
mod_person_id: my_person_id,
|
mod_person_id: my_person_id,
|
||||||
other_person_id: added_local_user.person.id,
|
other_person_id: added_local_user.person.id,
|
||||||
removed: Some(!data.added),
|
removed: Some(!data.added),
|
||||||
};
|
};
|
||||||
|
|
||||||
ModAdd::create(&mut context.pool(), &form).await?;
|
AdminAdd::create(&mut context.pool(), &form).await?;
|
||||||
|
|
||||||
let admins = PersonQuery {
|
let admins = PersonQuery {
|
||||||
admins_only: Some(true),
|
admins_only: Some(true),
|
||||||
|
|
|
@ -9,7 +9,7 @@ use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
instance::{InstanceActions, InstanceBanForm},
|
instance::{InstanceActions, InstanceBanForm},
|
||||||
local_user::LocalUser,
|
local_user::LocalUser,
|
||||||
mod_log::moderator::{ModBan, ModBanForm},
|
mod_log::admin::{AdminBan, AdminBanForm},
|
||||||
},
|
},
|
||||||
traits::{Bannable, Crud},
|
traits::{Bannable, Crud},
|
||||||
};
|
};
|
||||||
|
@ -65,7 +65,7 @@ pub async fn ban_from_site(
|
||||||
};
|
};
|
||||||
|
|
||||||
// Mod tables
|
// Mod tables
|
||||||
let form = ModBanForm {
|
let form = AdminBanForm {
|
||||||
mod_person_id: my_person_id,
|
mod_person_id: my_person_id,
|
||||||
other_person_id: data.person_id,
|
other_person_id: data.person_id,
|
||||||
reason: data.reason.clone(),
|
reason: data.reason.clone(),
|
||||||
|
@ -74,7 +74,7 @@ pub async fn ban_from_site(
|
||||||
instance_id: local_user_view.person.instance_id,
|
instance_id: local_user_view.person.instance_id,
|
||||||
};
|
};
|
||||||
|
|
||||||
ModBan::create(&mut context.pool(), &form).await?;
|
AdminBan::create(&mut context.pool(), &form).await?;
|
||||||
|
|
||||||
let person_view = PersonView::read(
|
let person_view = PersonView::read(
|
||||||
&mut context.pool(),
|
&mut context.pool(),
|
||||||
|
|
|
@ -6,7 +6,7 @@ use lemmy_db_schema::{
|
||||||
language::Language,
|
language::Language,
|
||||||
local_site_url_blocklist::LocalSiteUrlBlocklist,
|
local_site_url_blocklist::LocalSiteUrlBlocklist,
|
||||||
local_user::{LocalUser, LocalUserUpdateForm},
|
local_user::{LocalUser, LocalUserUpdateForm},
|
||||||
mod_log::moderator::{ModAdd, ModAddForm},
|
mod_log::admin::{AdminAdd, AdminAddForm},
|
||||||
oauth_provider::OAuthProvider,
|
oauth_provider::OAuthProvider,
|
||||||
tagline::Tagline,
|
tagline::Tagline,
|
||||||
},
|
},
|
||||||
|
@ -57,13 +57,13 @@ pub async fn leave_admin(
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Mod tables
|
// Mod tables
|
||||||
let form = ModAddForm {
|
let form = AdminAddForm {
|
||||||
mod_person_id: my_person_id,
|
mod_person_id: my_person_id,
|
||||||
other_person_id: my_person_id,
|
other_person_id: my_person_id,
|
||||||
removed: Some(true),
|
removed: Some(true),
|
||||||
};
|
};
|
||||||
|
|
||||||
ModAdd::create(&mut context.pool(), &form).await?;
|
AdminAdd::create(&mut context.pool(), &form).await?;
|
||||||
|
|
||||||
// Reread site and admins
|
// Reread site and admins
|
||||||
let site_view = SiteView::read_local(&mut context.pool()).await?;
|
let site_view = SiteView::read_local(&mut context.pool()).await?;
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
pub use lemmy_db_schema::{
|
pub use lemmy_db_schema::{
|
||||||
newtypes::{
|
newtypes::{
|
||||||
|
AdminAddId,
|
||||||
AdminAllowInstanceId,
|
AdminAllowInstanceId,
|
||||||
|
AdminBanId,
|
||||||
AdminBlockInstanceId,
|
AdminBlockInstanceId,
|
||||||
AdminPurgeCommentId,
|
AdminPurgeCommentId,
|
||||||
AdminPurgeCommunityId,
|
AdminPurgeCommunityId,
|
||||||
AdminPurgePersonId,
|
AdminPurgePersonId,
|
||||||
AdminPurgePostId,
|
AdminPurgePostId,
|
||||||
ModAddCommunityId,
|
AdminRemoveCommunityId,
|
||||||
ModAddId,
|
ModAddToCommunityId,
|
||||||
ModBanFromCommunityId,
|
ModBanFromCommunityId,
|
||||||
ModBanId,
|
|
||||||
ModChangeCommunityVisibilityId,
|
ModChangeCommunityVisibilityId,
|
||||||
ModFeaturePostId,
|
ModFeaturePostId,
|
||||||
ModLockPostId,
|
ModLockPostId,
|
||||||
ModRemoveCommentId,
|
ModRemoveCommentId,
|
||||||
ModRemoveCommunityId,
|
|
||||||
ModRemovePostId,
|
ModRemovePostId,
|
||||||
ModTransferCommunityId,
|
ModTransferCommunityId,
|
||||||
ModlogCombinedId,
|
ModlogCombinedId,
|
||||||
|
@ -23,23 +23,23 @@ pub use lemmy_db_schema::{
|
||||||
combined::modlog::ModlogCombined,
|
combined::modlog::ModlogCombined,
|
||||||
mod_log::{
|
mod_log::{
|
||||||
admin::{
|
admin::{
|
||||||
|
AdminAdd,
|
||||||
AdminAllowInstance,
|
AdminAllowInstance,
|
||||||
|
AdminBan,
|
||||||
AdminBlockInstance,
|
AdminBlockInstance,
|
||||||
AdminPurgeComment,
|
AdminPurgeComment,
|
||||||
AdminPurgeCommunity,
|
AdminPurgeCommunity,
|
||||||
AdminPurgePerson,
|
AdminPurgePerson,
|
||||||
AdminPurgePost,
|
AdminPurgePost,
|
||||||
|
AdminRemoveCommunity,
|
||||||
},
|
},
|
||||||
moderator::{
|
moderator::{
|
||||||
ModAdd,
|
ModAddToCommunity,
|
||||||
ModAddCommunity,
|
|
||||||
ModBan,
|
|
||||||
ModBanFromCommunity,
|
ModBanFromCommunity,
|
||||||
ModChangeCommunityVisibility,
|
ModChangeCommunityVisibility,
|
||||||
ModFeaturePost,
|
ModFeaturePost,
|
||||||
ModLockPost,
|
ModLockPost,
|
||||||
ModRemoveComment,
|
ModRemoveComment,
|
||||||
ModRemoveCommunity,
|
|
||||||
ModRemovePost,
|
ModRemovePost,
|
||||||
ModTransferCommunity,
|
ModTransferCommunity,
|
||||||
},
|
},
|
||||||
|
@ -49,21 +49,21 @@ pub use lemmy_db_schema::{
|
||||||
};
|
};
|
||||||
pub use lemmy_db_views_modlog_combined::{
|
pub use lemmy_db_views_modlog_combined::{
|
||||||
api::{GetModlog, GetModlogResponse},
|
api::{GetModlog, GetModlogResponse},
|
||||||
|
AdminAddView,
|
||||||
AdminAllowInstanceView,
|
AdminAllowInstanceView,
|
||||||
|
AdminBanView,
|
||||||
AdminBlockInstanceView,
|
AdminBlockInstanceView,
|
||||||
AdminPurgeCommentView,
|
AdminPurgeCommentView,
|
||||||
AdminPurgeCommunityView,
|
AdminPurgeCommunityView,
|
||||||
AdminPurgePersonView,
|
AdminPurgePersonView,
|
||||||
AdminPurgePostView,
|
AdminPurgePostView,
|
||||||
ModAddCommunityView,
|
AdminRemoveCommunityView,
|
||||||
ModAddView,
|
ModAddToCommunityView,
|
||||||
ModBanFromCommunityView,
|
ModBanFromCommunityView,
|
||||||
ModBanView,
|
|
||||||
ModChangeCommunityVisibilityView,
|
ModChangeCommunityVisibilityView,
|
||||||
ModFeaturePostView,
|
ModFeaturePostView,
|
||||||
ModLockPostView,
|
ModLockPostView,
|
||||||
ModRemoveCommentView,
|
ModRemoveCommentView,
|
||||||
ModRemoveCommunityView,
|
|
||||||
ModRemovePostView,
|
ModRemovePostView,
|
||||||
ModTransferCommunityView,
|
ModTransferCommunityView,
|
||||||
ModlogCombinedView,
|
ModlogCombinedView,
|
||||||
|
|
|
@ -10,7 +10,7 @@ use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
community::{Community, CommunityUpdateForm},
|
community::{Community, CommunityUpdateForm},
|
||||||
community_report::CommunityReport,
|
community_report::CommunityReport,
|
||||||
mod_log::moderator::{ModRemoveCommunity, ModRemoveCommunityForm},
|
mod_log::admin::{AdminRemoveCommunity, AdminRemoveCommunityForm},
|
||||||
},
|
},
|
||||||
traits::{Crud, Reportable},
|
traits::{Crud, Reportable},
|
||||||
};
|
};
|
||||||
|
@ -50,13 +50,13 @@ pub async fn remove_community(
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Mod tables
|
// Mod tables
|
||||||
let form = ModRemoveCommunityForm {
|
let form = AdminRemoveCommunityForm {
|
||||||
mod_person_id: local_user_view.person.id,
|
mod_person_id: local_user_view.person.id,
|
||||||
community_id: data.community_id,
|
community_id: data.community_id,
|
||||||
removed: Some(removed),
|
removed: Some(removed),
|
||||||
reason: data.reason.clone(),
|
reason: data.reason.clone(),
|
||||||
};
|
};
|
||||||
ModRemoveCommunity::create(&mut context.pool(), &form).await?;
|
AdminRemoveCommunity::create(&mut context.pool(), &form).await?;
|
||||||
|
|
||||||
ActivityChannel::submit_activity(
|
ActivityChannel::submit_activity(
|
||||||
SendActivityData::RemoveCommunity {
|
SendActivityData::RemoveCommunity {
|
||||||
|
|
|
@ -33,7 +33,10 @@ use lemmy_db_schema::{
|
||||||
activity::ActivitySendTargets,
|
activity::ActivitySendTargets,
|
||||||
community::{CommunityActions, CommunityPersonBanForm},
|
community::{CommunityActions, CommunityPersonBanForm},
|
||||||
instance::{InstanceActions, InstanceBanForm},
|
instance::{InstanceActions, InstanceBanForm},
|
||||||
mod_log::moderator::{ModBan, ModBanForm, ModBanFromCommunity, ModBanFromCommunityForm},
|
mod_log::{
|
||||||
|
admin::{AdminBan, AdminBanForm},
|
||||||
|
moderator::{ModBanFromCommunity, ModBanFromCommunityForm},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
traits::{Bannable, Crud},
|
traits::{Bannable, Crud},
|
||||||
};
|
};
|
||||||
|
@ -149,7 +152,7 @@ impl Activity for BlockUser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// write mod log
|
// write mod log
|
||||||
let form = ModBanForm {
|
let form = AdminBanForm {
|
||||||
mod_person_id: mod_person.id,
|
mod_person_id: mod_person.id,
|
||||||
other_person_id: blocked_person.id,
|
other_person_id: blocked_person.id,
|
||||||
reason,
|
reason,
|
||||||
|
@ -157,7 +160,7 @@ impl Activity for BlockUser {
|
||||||
expires_at,
|
expires_at,
|
||||||
instance_id: site.instance_id,
|
instance_id: site.instance_id,
|
||||||
};
|
};
|
||||||
ModBan::create(&mut context.pool(), &form).await?;
|
AdminBan::create(&mut context.pool(), &form).await?;
|
||||||
}
|
}
|
||||||
SiteOrCommunity::Right(community) => {
|
SiteOrCommunity::Right(community) => {
|
||||||
let community_user_ban_form = CommunityPersonBanForm {
|
let community_user_ban_form = CommunityPersonBanForm {
|
||||||
|
|
|
@ -28,7 +28,10 @@ use lemmy_db_schema::{
|
||||||
activity::ActivitySendTargets,
|
activity::ActivitySendTargets,
|
||||||
community::{CommunityActions, CommunityPersonBanForm},
|
community::{CommunityActions, CommunityPersonBanForm},
|
||||||
instance::{InstanceActions, InstanceBanForm},
|
instance::{InstanceActions, InstanceBanForm},
|
||||||
mod_log::moderator::{ModBan, ModBanForm, ModBanFromCommunity, ModBanFromCommunityForm},
|
mod_log::{
|
||||||
|
admin::{AdminBan, AdminBanForm},
|
||||||
|
moderator::{ModBanFromCommunity, ModBanFromCommunityForm},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
traits::{Bannable, Crud},
|
traits::{Bannable, Crud},
|
||||||
};
|
};
|
||||||
|
@ -113,7 +116,7 @@ impl Activity for UndoBlockUser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// write mod log
|
// write mod log
|
||||||
let form = ModBanForm {
|
let form = AdminBanForm {
|
||||||
mod_person_id: mod_person.id,
|
mod_person_id: mod_person.id,
|
||||||
other_person_id: blocked_person.id,
|
other_person_id: blocked_person.id,
|
||||||
reason: self.object.summary,
|
reason: self.object.summary,
|
||||||
|
@ -121,7 +124,7 @@ impl Activity for UndoBlockUser {
|
||||||
expires_at,
|
expires_at,
|
||||||
instance_id: site.instance_id,
|
instance_id: site.instance_id,
|
||||||
};
|
};
|
||||||
ModBan::create(&mut context.pool(), &form).await?;
|
AdminBan::create(&mut context.pool(), &form).await?;
|
||||||
}
|
}
|
||||||
SiteOrCommunity::Right(community) => {
|
SiteOrCommunity::Right(community) => {
|
||||||
verify_visibility(&self.to, &self.cc, &community)?;
|
verify_visibility(&self.to, &self.cc, &community)?;
|
||||||
|
|
|
@ -29,7 +29,7 @@ use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
activity::ActivitySendTargets,
|
activity::ActivitySendTargets,
|
||||||
community::{Community, CommunityActions, CommunityModeratorForm},
|
community::{Community, CommunityActions, CommunityModeratorForm},
|
||||||
mod_log::moderator::{ModAddCommunity, ModAddCommunityForm},
|
mod_log::moderator::{ModAddToCommunity, ModAddToCommunityForm},
|
||||||
person::Person,
|
person::Person,
|
||||||
post::{Post, PostUpdateForm},
|
post::{Post, PostUpdateForm},
|
||||||
},
|
},
|
||||||
|
@ -132,13 +132,13 @@ impl Activity for CollectionAdd {
|
||||||
|
|
||||||
// write mod log
|
// write mod log
|
||||||
let actor = self.actor.dereference(context).await?;
|
let actor = self.actor.dereference(context).await?;
|
||||||
let form = ModAddCommunityForm {
|
let form = ModAddToCommunityForm {
|
||||||
mod_person_id: actor.id,
|
mod_person_id: actor.id,
|
||||||
other_person_id: new_mod.id,
|
other_person_id: new_mod.id,
|
||||||
community_id: community.id,
|
community_id: community.id,
|
||||||
removed: Some(false),
|
removed: Some(false),
|
||||||
};
|
};
|
||||||
ModAddCommunity::create(&mut context.pool(), &form).await?;
|
ModAddToCommunity::create(&mut context.pool(), &form).await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CollectionType::Featured => {
|
CollectionType::Featured => {
|
||||||
|
|
|
@ -25,7 +25,7 @@ use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
activity::ActivitySendTargets,
|
activity::ActivitySendTargets,
|
||||||
community::{Community, CommunityActions, CommunityModeratorForm},
|
community::{Community, CommunityActions, CommunityModeratorForm},
|
||||||
mod_log::moderator::{ModAddCommunity, ModAddCommunityForm},
|
mod_log::moderator::{ModAddToCommunity, ModAddToCommunityForm},
|
||||||
post::{Post, PostUpdateForm},
|
post::{Post, PostUpdateForm},
|
||||||
},
|
},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
|
@ -120,13 +120,13 @@ impl Activity for CollectionRemove {
|
||||||
|
|
||||||
// write mod log
|
// write mod log
|
||||||
let actor = self.actor.dereference(context).await?;
|
let actor = self.actor.dereference(context).await?;
|
||||||
let form = ModAddCommunityForm {
|
let form = ModAddToCommunityForm {
|
||||||
mod_person_id: actor.id,
|
mod_person_id: actor.id,
|
||||||
other_person_id: remove_mod.id,
|
other_person_id: remove_mod.id,
|
||||||
community_id: community.id,
|
community_id: community.id,
|
||||||
removed: Some(true),
|
removed: Some(true),
|
||||||
};
|
};
|
||||||
ModAddCommunity::create(&mut context.pool(), &form).await?;
|
ModAddToCommunity::create(&mut context.pool(), &form).await?;
|
||||||
|
|
||||||
// TODO: send websocket notification about removed mod
|
// TODO: send websocket notification about removed mod
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,13 +14,9 @@ use lemmy_db_schema::{
|
||||||
comment_report::CommentReport,
|
comment_report::CommentReport,
|
||||||
community::{Community, CommunityUpdateForm},
|
community::{Community, CommunityUpdateForm},
|
||||||
community_report::CommunityReport,
|
community_report::CommunityReport,
|
||||||
mod_log::moderator::{
|
mod_log::{
|
||||||
ModRemoveComment,
|
admin::{AdminRemoveCommunity, AdminRemoveCommunityForm},
|
||||||
ModRemoveCommentForm,
|
moderator::{ModRemoveComment, ModRemoveCommentForm, ModRemovePost, ModRemovePostForm},
|
||||||
ModRemoveCommunity,
|
|
||||||
ModRemoveCommunityForm,
|
|
||||||
ModRemovePost,
|
|
||||||
ModRemovePostForm,
|
|
||||||
},
|
},
|
||||||
post::{Post, PostUpdateForm},
|
post::{Post, PostUpdateForm},
|
||||||
post_report::PostReport,
|
post_report::PostReport,
|
||||||
|
@ -113,13 +109,13 @@ pub(in crate::activities) async fn receive_remove_action(
|
||||||
Err(FederationError::OnlyLocalAdminCanRemoveCommunity)?
|
Err(FederationError::OnlyLocalAdminCanRemoveCommunity)?
|
||||||
}
|
}
|
||||||
CommunityReport::resolve_all_for_object(&mut context.pool(), community.id, actor.id).await?;
|
CommunityReport::resolve_all_for_object(&mut context.pool(), community.id, actor.id).await?;
|
||||||
let form = ModRemoveCommunityForm {
|
let form = AdminRemoveCommunityForm {
|
||||||
mod_person_id: actor.id,
|
mod_person_id: actor.id,
|
||||||
community_id: community.id,
|
community_id: community.id,
|
||||||
removed: Some(true),
|
removed: Some(true),
|
||||||
reason,
|
reason,
|
||||||
};
|
};
|
||||||
ModRemoveCommunity::create(&mut context.pool(), &form).await?;
|
AdminRemoveCommunity::create(&mut context.pool(), &form).await?;
|
||||||
Community::update(
|
Community::update(
|
||||||
&mut context.pool(),
|
&mut context.pool(),
|
||||||
community.id,
|
community.id,
|
||||||
|
|
|
@ -12,13 +12,9 @@ use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
comment::{Comment, CommentUpdateForm},
|
comment::{Comment, CommentUpdateForm},
|
||||||
community::{Community, CommunityUpdateForm},
|
community::{Community, CommunityUpdateForm},
|
||||||
mod_log::moderator::{
|
mod_log::{
|
||||||
ModRemoveComment,
|
admin::{AdminRemoveCommunity, AdminRemoveCommunityForm},
|
||||||
ModRemoveCommentForm,
|
moderator::{ModRemoveComment, ModRemoveCommentForm, ModRemovePost, ModRemovePostForm},
|
||||||
ModRemoveCommunity,
|
|
||||||
ModRemoveCommunityForm,
|
|
||||||
ModRemovePost,
|
|
||||||
ModRemovePostForm,
|
|
||||||
},
|
},
|
||||||
post::{Post, PostUpdateForm},
|
post::{Post, PostUpdateForm},
|
||||||
},
|
},
|
||||||
|
@ -93,13 +89,13 @@ impl UndoDelete {
|
||||||
if community.local {
|
if community.local {
|
||||||
Err(FederationError::OnlyLocalAdminCanRestoreCommunity)?
|
Err(FederationError::OnlyLocalAdminCanRestoreCommunity)?
|
||||||
}
|
}
|
||||||
let form = ModRemoveCommunityForm {
|
let form = AdminRemoveCommunityForm {
|
||||||
mod_person_id: actor.id,
|
mod_person_id: actor.id,
|
||||||
community_id: community.id,
|
community_id: community.id,
|
||||||
removed: Some(false),
|
removed: Some(false),
|
||||||
reason: None,
|
reason: None,
|
||||||
};
|
};
|
||||||
ModRemoveCommunity::create(&mut context.pool(), &form).await?;
|
AdminRemoveCommunity::create(&mut context.pool(), &form).await?;
|
||||||
Community::update(
|
Community::update(
|
||||||
&mut context.pool(),
|
&mut context.pool(),
|
||||||
community.id,
|
community.id,
|
||||||
|
|
|
@ -1,15 +1,22 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
newtypes::{
|
newtypes::{
|
||||||
|
AdminAddId,
|
||||||
AdminAllowInstanceId,
|
AdminAllowInstanceId,
|
||||||
|
AdminBanId,
|
||||||
AdminBlockInstanceId,
|
AdminBlockInstanceId,
|
||||||
AdminPurgeCommentId,
|
AdminPurgeCommentId,
|
||||||
AdminPurgeCommunityId,
|
AdminPurgeCommunityId,
|
||||||
AdminPurgePersonId,
|
AdminPurgePersonId,
|
||||||
AdminPurgePostId,
|
AdminPurgePostId,
|
||||||
|
AdminRemoveCommunityId,
|
||||||
},
|
},
|
||||||
source::mod_log::admin::{
|
source::mod_log::admin::{
|
||||||
|
AdminAdd,
|
||||||
|
AdminAddForm,
|
||||||
AdminAllowInstance,
|
AdminAllowInstance,
|
||||||
AdminAllowInstanceForm,
|
AdminAllowInstanceForm,
|
||||||
|
AdminBan,
|
||||||
|
AdminBanForm,
|
||||||
AdminBlockInstance,
|
AdminBlockInstance,
|
||||||
AdminBlockInstanceForm,
|
AdminBlockInstanceForm,
|
||||||
AdminPurgeComment,
|
AdminPurgeComment,
|
||||||
|
@ -20,6 +27,8 @@ use crate::{
|
||||||
AdminPurgePersonForm,
|
AdminPurgePersonForm,
|
||||||
AdminPurgePost,
|
AdminPurgePost,
|
||||||
AdminPurgePostForm,
|
AdminPurgePostForm,
|
||||||
|
AdminRemoveCommunity,
|
||||||
|
AdminRemoveCommunityForm,
|
||||||
},
|
},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
utils::{get_conn, DbPool},
|
utils::{get_conn, DbPool},
|
||||||
|
@ -27,12 +36,15 @@ use crate::{
|
||||||
use diesel::{dsl::insert_into, QueryDsl};
|
use diesel::{dsl::insert_into, QueryDsl};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema_file::schema::{
|
use lemmy_db_schema_file::schema::{
|
||||||
|
admin_add,
|
||||||
admin_allow_instance,
|
admin_allow_instance,
|
||||||
|
admin_ban,
|
||||||
admin_block_instance,
|
admin_block_instance,
|
||||||
admin_purge_comment,
|
admin_purge_comment,
|
||||||
admin_purge_community,
|
admin_purge_community,
|
||||||
admin_purge_person,
|
admin_purge_person,
|
||||||
admin_purge_post,
|
admin_purge_post,
|
||||||
|
admin_remove_community,
|
||||||
};
|
};
|
||||||
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
||||||
|
|
||||||
|
@ -203,3 +215,87 @@ impl Crud for AdminBlockInstance {
|
||||||
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
|
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Crud for AdminRemoveCommunity {
|
||||||
|
type InsertForm = AdminRemoveCommunityForm;
|
||||||
|
type UpdateForm = AdminRemoveCommunityForm;
|
||||||
|
type IdType = AdminRemoveCommunityId;
|
||||||
|
|
||||||
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> LemmyResult<Self> {
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
insert_into(admin_remove_community::table)
|
||||||
|
.values(form)
|
||||||
|
.get_result::<Self>(conn)
|
||||||
|
.await
|
||||||
|
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update(
|
||||||
|
pool: &mut DbPool<'_>,
|
||||||
|
from_id: Self::IdType,
|
||||||
|
form: &Self::UpdateForm,
|
||||||
|
) -> LemmyResult<Self> {
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
diesel::update(admin_remove_community::table.find(from_id))
|
||||||
|
.set(form)
|
||||||
|
.get_result::<Self>(conn)
|
||||||
|
.await
|
||||||
|
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Crud for AdminBan {
|
||||||
|
type InsertForm = AdminBanForm;
|
||||||
|
type UpdateForm = AdminBanForm;
|
||||||
|
type IdType = AdminBanId;
|
||||||
|
|
||||||
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> LemmyResult<Self> {
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
insert_into(admin_ban::table)
|
||||||
|
.values(form)
|
||||||
|
.get_result::<Self>(conn)
|
||||||
|
.await
|
||||||
|
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update(
|
||||||
|
pool: &mut DbPool<'_>,
|
||||||
|
from_id: Self::IdType,
|
||||||
|
form: &Self::UpdateForm,
|
||||||
|
) -> LemmyResult<Self> {
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
diesel::update(admin_ban::table.find(from_id))
|
||||||
|
.set(form)
|
||||||
|
.get_result::<Self>(conn)
|
||||||
|
.await
|
||||||
|
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Crud for AdminAdd {
|
||||||
|
type InsertForm = AdminAddForm;
|
||||||
|
type UpdateForm = AdminAddForm;
|
||||||
|
type IdType = AdminAddId;
|
||||||
|
|
||||||
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> LemmyResult<Self> {
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
insert_into(admin_add::table)
|
||||||
|
.values(form)
|
||||||
|
.get_result::<Self>(conn)
|
||||||
|
.await
|
||||||
|
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update(
|
||||||
|
pool: &mut DbPool<'_>,
|
||||||
|
from_id: Self::IdType,
|
||||||
|
form: &Self::UpdateForm,
|
||||||
|
) -> LemmyResult<Self> {
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
diesel::update(admin_add::table.find(from_id))
|
||||||
|
.set(form)
|
||||||
|
.get_result::<Self>(conn)
|
||||||
|
.await
|
||||||
|
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,2 +1,267 @@
|
||||||
pub mod admin;
|
pub mod admin;
|
||||||
pub mod moderator;
|
pub mod moderator;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
source::{
|
||||||
|
comment::{Comment, CommentInsertForm},
|
||||||
|
community::{Community, CommunityInsertForm},
|
||||||
|
instance::Instance,
|
||||||
|
mod_log::{admin::*, moderator::*},
|
||||||
|
person::{Person, PersonInsertForm},
|
||||||
|
post::{Post, PostInsertForm},
|
||||||
|
},
|
||||||
|
traits::Crud,
|
||||||
|
utils::build_db_pool_for_tests,
|
||||||
|
};
|
||||||
|
use lemmy_utils::error::LemmyResult;
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
|
use serial_test::serial;
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
#[serial]
|
||||||
|
async fn test_crud() -> LemmyResult<()> {
|
||||||
|
let pool = &build_db_pool_for_tests();
|
||||||
|
let pool = &mut pool.into();
|
||||||
|
|
||||||
|
let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()).await?;
|
||||||
|
|
||||||
|
let new_mod = PersonInsertForm::test_form(inserted_instance.id, "the mod");
|
||||||
|
|
||||||
|
let inserted_mod = Person::create(pool, &new_mod).await?;
|
||||||
|
|
||||||
|
let new_person = PersonInsertForm::test_form(inserted_instance.id, "jim2");
|
||||||
|
|
||||||
|
let inserted_person = Person::create(pool, &new_person).await?;
|
||||||
|
|
||||||
|
let new_community = CommunityInsertForm::new(
|
||||||
|
inserted_instance.id,
|
||||||
|
"mod_community".to_string(),
|
||||||
|
"nada".to_owned(),
|
||||||
|
"pubkey".to_string(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let inserted_community = Community::create(pool, &new_community).await?;
|
||||||
|
|
||||||
|
let new_post = PostInsertForm::new(
|
||||||
|
"A test post thweep".into(),
|
||||||
|
inserted_person.id,
|
||||||
|
inserted_community.id,
|
||||||
|
);
|
||||||
|
let inserted_post = Post::create(pool, &new_post).await?;
|
||||||
|
|
||||||
|
let comment_form = CommentInsertForm::new(
|
||||||
|
inserted_person.id,
|
||||||
|
inserted_post.id,
|
||||||
|
"A test comment".into(),
|
||||||
|
);
|
||||||
|
let inserted_comment = Comment::create(pool, &comment_form, None).await?;
|
||||||
|
|
||||||
|
// Now the actual tests
|
||||||
|
|
||||||
|
// remove post
|
||||||
|
let mod_remove_post_form = ModRemovePostForm {
|
||||||
|
mod_person_id: inserted_mod.id,
|
||||||
|
post_id: inserted_post.id,
|
||||||
|
reason: None,
|
||||||
|
removed: None,
|
||||||
|
};
|
||||||
|
let inserted_mod_remove_post = ModRemovePost::create(pool, &mod_remove_post_form).await?;
|
||||||
|
let read_mod_remove_post = ModRemovePost::read(pool, inserted_mod_remove_post.id).await?;
|
||||||
|
let expected_mod_remove_post = ModRemovePost {
|
||||||
|
id: inserted_mod_remove_post.id,
|
||||||
|
post_id: inserted_post.id,
|
||||||
|
mod_person_id: inserted_mod.id,
|
||||||
|
reason: None,
|
||||||
|
removed: true,
|
||||||
|
published_at: inserted_mod_remove_post.published_at,
|
||||||
|
};
|
||||||
|
|
||||||
|
// lock post
|
||||||
|
|
||||||
|
let mod_lock_post_form = ModLockPostForm {
|
||||||
|
mod_person_id: inserted_mod.id,
|
||||||
|
post_id: inserted_post.id,
|
||||||
|
locked: None,
|
||||||
|
reason: None,
|
||||||
|
};
|
||||||
|
let inserted_mod_lock_post = ModLockPost::create(pool, &mod_lock_post_form).await?;
|
||||||
|
let read_mod_lock_post = ModLockPost::read(pool, inserted_mod_lock_post.id).await?;
|
||||||
|
let expected_mod_lock_post = ModLockPost {
|
||||||
|
id: inserted_mod_lock_post.id,
|
||||||
|
post_id: inserted_post.id,
|
||||||
|
mod_person_id: inserted_mod.id,
|
||||||
|
locked: true,
|
||||||
|
reason: None,
|
||||||
|
published_at: inserted_mod_lock_post.published_at,
|
||||||
|
};
|
||||||
|
|
||||||
|
// feature post
|
||||||
|
|
||||||
|
let mod_feature_post_form = ModFeaturePostForm {
|
||||||
|
mod_person_id: inserted_mod.id,
|
||||||
|
post_id: inserted_post.id,
|
||||||
|
featured: Some(false),
|
||||||
|
is_featured_community: Some(true),
|
||||||
|
};
|
||||||
|
let inserted_mod_feature_post = ModFeaturePost::create(pool, &mod_feature_post_form).await?;
|
||||||
|
let read_mod_feature_post = ModFeaturePost::read(pool, inserted_mod_feature_post.id).await?;
|
||||||
|
let expected_mod_feature_post = ModFeaturePost {
|
||||||
|
id: inserted_mod_feature_post.id,
|
||||||
|
post_id: inserted_post.id,
|
||||||
|
mod_person_id: inserted_mod.id,
|
||||||
|
featured: false,
|
||||||
|
is_featured_community: true,
|
||||||
|
published_at: inserted_mod_feature_post.published_at,
|
||||||
|
};
|
||||||
|
|
||||||
|
// comment
|
||||||
|
|
||||||
|
let mod_remove_comment_form = ModRemoveCommentForm {
|
||||||
|
mod_person_id: inserted_mod.id,
|
||||||
|
comment_id: inserted_comment.id,
|
||||||
|
reason: None,
|
||||||
|
removed: None,
|
||||||
|
};
|
||||||
|
let inserted_mod_remove_comment =
|
||||||
|
ModRemoveComment::create(pool, &mod_remove_comment_form).await?;
|
||||||
|
let read_mod_remove_comment =
|
||||||
|
ModRemoveComment::read(pool, inserted_mod_remove_comment.id).await?;
|
||||||
|
let expected_mod_remove_comment = ModRemoveComment {
|
||||||
|
id: inserted_mod_remove_comment.id,
|
||||||
|
comment_id: inserted_comment.id,
|
||||||
|
mod_person_id: inserted_mod.id,
|
||||||
|
reason: None,
|
||||||
|
removed: true,
|
||||||
|
published_at: inserted_mod_remove_comment.published_at,
|
||||||
|
};
|
||||||
|
|
||||||
|
// community
|
||||||
|
|
||||||
|
let admin_remove_community_form = AdminRemoveCommunityForm {
|
||||||
|
mod_person_id: inserted_mod.id,
|
||||||
|
community_id: inserted_community.id,
|
||||||
|
reason: None,
|
||||||
|
removed: None,
|
||||||
|
};
|
||||||
|
let inserted_admin_remove_community =
|
||||||
|
AdminRemoveCommunity::create(pool, &admin_remove_community_form).await?;
|
||||||
|
let read_mod_remove_community =
|
||||||
|
AdminRemoveCommunity::read(pool, inserted_admin_remove_community.id).await?;
|
||||||
|
let expected_admin_remove_community = AdminRemoveCommunity {
|
||||||
|
id: inserted_admin_remove_community.id,
|
||||||
|
community_id: inserted_community.id,
|
||||||
|
mod_person_id: inserted_mod.id,
|
||||||
|
reason: None,
|
||||||
|
removed: true,
|
||||||
|
published_at: inserted_admin_remove_community.published_at,
|
||||||
|
};
|
||||||
|
|
||||||
|
// ban from community
|
||||||
|
|
||||||
|
let mod_ban_from_community_form = ModBanFromCommunityForm {
|
||||||
|
mod_person_id: inserted_mod.id,
|
||||||
|
other_person_id: inserted_person.id,
|
||||||
|
community_id: inserted_community.id,
|
||||||
|
reason: None,
|
||||||
|
banned: None,
|
||||||
|
expires_at: None,
|
||||||
|
};
|
||||||
|
let inserted_mod_ban_from_community =
|
||||||
|
ModBanFromCommunity::create(pool, &mod_ban_from_community_form).await?;
|
||||||
|
let read_mod_ban_from_community =
|
||||||
|
ModBanFromCommunity::read(pool, inserted_mod_ban_from_community.id).await?;
|
||||||
|
let expected_mod_ban_from_community = ModBanFromCommunity {
|
||||||
|
id: inserted_mod_ban_from_community.id,
|
||||||
|
community_id: inserted_community.id,
|
||||||
|
mod_person_id: inserted_mod.id,
|
||||||
|
other_person_id: inserted_person.id,
|
||||||
|
reason: None,
|
||||||
|
banned: true,
|
||||||
|
expires_at: None,
|
||||||
|
published_at: inserted_mod_ban_from_community.published_at,
|
||||||
|
};
|
||||||
|
|
||||||
|
// ban
|
||||||
|
|
||||||
|
let admin_ban_form = AdminBanForm {
|
||||||
|
mod_person_id: inserted_mod.id,
|
||||||
|
other_person_id: inserted_person.id,
|
||||||
|
reason: None,
|
||||||
|
banned: None,
|
||||||
|
expires_at: None,
|
||||||
|
instance_id: inserted_instance.id,
|
||||||
|
};
|
||||||
|
let inserted_admin_ban = AdminBan::create(pool, &admin_ban_form).await?;
|
||||||
|
let read_mod_ban = AdminBan::read(pool, inserted_admin_ban.id).await?;
|
||||||
|
let expected_admin_ban = AdminBan {
|
||||||
|
id: inserted_admin_ban.id,
|
||||||
|
mod_person_id: inserted_mod.id,
|
||||||
|
other_person_id: inserted_person.id,
|
||||||
|
reason: None,
|
||||||
|
banned: true,
|
||||||
|
expires_at: None,
|
||||||
|
published_at: inserted_admin_ban.published_at,
|
||||||
|
instance_id: inserted_instance.id,
|
||||||
|
};
|
||||||
|
|
||||||
|
// mod add community
|
||||||
|
|
||||||
|
let mod_add_to_community_form = ModAddToCommunityForm {
|
||||||
|
mod_person_id: inserted_mod.id,
|
||||||
|
other_person_id: inserted_person.id,
|
||||||
|
community_id: inserted_community.id,
|
||||||
|
removed: None,
|
||||||
|
};
|
||||||
|
let inserted_mod_add_to_community =
|
||||||
|
ModAddToCommunity::create(pool, &mod_add_to_community_form).await?;
|
||||||
|
let read_mod_add_to_community =
|
||||||
|
ModAddToCommunity::read(pool, inserted_mod_add_to_community.id).await?;
|
||||||
|
let expected_mod_add_to_community = ModAddToCommunity {
|
||||||
|
id: inserted_mod_add_to_community.id,
|
||||||
|
community_id: inserted_community.id,
|
||||||
|
mod_person_id: inserted_mod.id,
|
||||||
|
other_person_id: inserted_person.id,
|
||||||
|
removed: false,
|
||||||
|
published_at: inserted_mod_add_to_community.published_at,
|
||||||
|
};
|
||||||
|
|
||||||
|
// admin add
|
||||||
|
|
||||||
|
let admin_add_form = AdminAddForm {
|
||||||
|
mod_person_id: inserted_mod.id,
|
||||||
|
other_person_id: inserted_person.id,
|
||||||
|
removed: None,
|
||||||
|
};
|
||||||
|
let inserted_admin_add = AdminAdd::create(pool, &admin_add_form).await?;
|
||||||
|
let read_mod_add = AdminAdd::read(pool, inserted_admin_add.id).await?;
|
||||||
|
let expected_admin_add = AdminAdd {
|
||||||
|
id: inserted_admin_add.id,
|
||||||
|
mod_person_id: inserted_mod.id,
|
||||||
|
other_person_id: inserted_person.id,
|
||||||
|
removed: false,
|
||||||
|
published_at: inserted_admin_add.published_at,
|
||||||
|
};
|
||||||
|
|
||||||
|
Comment::delete(pool, inserted_comment.id).await?;
|
||||||
|
Post::delete(pool, inserted_post.id).await?;
|
||||||
|
Community::delete(pool, inserted_community.id).await?;
|
||||||
|
Person::delete(pool, inserted_person.id).await?;
|
||||||
|
Person::delete(pool, inserted_mod.id).await?;
|
||||||
|
Instance::delete(pool, inserted_instance.id).await?;
|
||||||
|
|
||||||
|
assert_eq!(expected_mod_remove_post, read_mod_remove_post);
|
||||||
|
assert_eq!(expected_mod_lock_post, read_mod_lock_post);
|
||||||
|
assert_eq!(expected_mod_feature_post, read_mod_feature_post);
|
||||||
|
assert_eq!(expected_mod_remove_comment, read_mod_remove_comment);
|
||||||
|
assert_eq!(expected_admin_remove_community, read_mod_remove_community);
|
||||||
|
assert_eq!(expected_mod_ban_from_community, read_mod_ban_from_community);
|
||||||
|
assert_eq!(expected_admin_ban, read_mod_ban);
|
||||||
|
assert_eq!(expected_mod_add_to_community, read_mod_add_to_community);
|
||||||
|
assert_eq!(expected_admin_add, read_mod_add);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,24 +1,17 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
newtypes::{
|
newtypes::{
|
||||||
ModAddCommunityId,
|
ModAddToCommunityId,
|
||||||
ModAddId,
|
|
||||||
ModBanFromCommunityId,
|
ModBanFromCommunityId,
|
||||||
ModBanId,
|
|
||||||
ModChangeCommunityVisibilityId,
|
ModChangeCommunityVisibilityId,
|
||||||
ModFeaturePostId,
|
ModFeaturePostId,
|
||||||
ModLockPostId,
|
ModLockPostId,
|
||||||
ModRemoveCommentId,
|
ModRemoveCommentId,
|
||||||
ModRemoveCommunityId,
|
|
||||||
ModRemovePostId,
|
ModRemovePostId,
|
||||||
ModTransferCommunityId,
|
ModTransferCommunityId,
|
||||||
},
|
},
|
||||||
source::mod_log::moderator::{
|
source::mod_log::moderator::{
|
||||||
ModAdd,
|
ModAddToCommunity,
|
||||||
ModAddCommunity,
|
ModAddToCommunityForm,
|
||||||
ModAddCommunityForm,
|
|
||||||
ModAddForm,
|
|
||||||
ModBan,
|
|
||||||
ModBanForm,
|
|
||||||
ModBanFromCommunity,
|
ModBanFromCommunity,
|
||||||
ModBanFromCommunityForm,
|
ModBanFromCommunityForm,
|
||||||
ModChangeCommunityVisibility,
|
ModChangeCommunityVisibility,
|
||||||
|
@ -29,8 +22,6 @@ use crate::{
|
||||||
ModLockPostForm,
|
ModLockPostForm,
|
||||||
ModRemoveComment,
|
ModRemoveComment,
|
||||||
ModRemoveCommentForm,
|
ModRemoveCommentForm,
|
||||||
ModRemoveCommunity,
|
|
||||||
ModRemoveCommunityForm,
|
|
||||||
ModRemovePost,
|
ModRemovePost,
|
||||||
ModRemovePostForm,
|
ModRemovePostForm,
|
||||||
ModTransferCommunity,
|
ModTransferCommunity,
|
||||||
|
@ -42,15 +33,12 @@ use crate::{
|
||||||
use diesel::{dsl::insert_into, QueryDsl};
|
use diesel::{dsl::insert_into, QueryDsl};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema_file::schema::{
|
use lemmy_db_schema_file::schema::{
|
||||||
mod_add,
|
mod_add_to_community,
|
||||||
mod_add_community,
|
|
||||||
mod_ban,
|
|
||||||
mod_ban_from_community,
|
mod_ban_from_community,
|
||||||
mod_change_community_visibility,
|
mod_change_community_visibility,
|
||||||
mod_feature_post,
|
mod_feature_post,
|
||||||
mod_lock_post,
|
mod_lock_post,
|
||||||
mod_remove_comment,
|
mod_remove_comment,
|
||||||
mod_remove_community,
|
|
||||||
mod_remove_post,
|
mod_remove_post,
|
||||||
mod_transfer_community,
|
mod_transfer_community,
|
||||||
};
|
};
|
||||||
|
@ -196,34 +184,6 @@ impl ModRemoveComment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Crud for ModRemoveCommunity {
|
|
||||||
type InsertForm = ModRemoveCommunityForm;
|
|
||||||
type UpdateForm = ModRemoveCommunityForm;
|
|
||||||
type IdType = ModRemoveCommunityId;
|
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> LemmyResult<Self> {
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
|
||||||
insert_into(mod_remove_community::table)
|
|
||||||
.values(form)
|
|
||||||
.get_result::<Self>(conn)
|
|
||||||
.await
|
|
||||||
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn update(
|
|
||||||
pool: &mut DbPool<'_>,
|
|
||||||
from_id: Self::IdType,
|
|
||||||
form: &Self::UpdateForm,
|
|
||||||
) -> LemmyResult<Self> {
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
|
||||||
diesel::update(mod_remove_community::table.find(from_id))
|
|
||||||
.set(form)
|
|
||||||
.get_result::<Self>(conn)
|
|
||||||
.await
|
|
||||||
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Crud for ModBanFromCommunity {
|
impl Crud for ModBanFromCommunity {
|
||||||
type InsertForm = ModBanFromCommunityForm;
|
type InsertForm = ModBanFromCommunityForm;
|
||||||
type UpdateForm = ModBanFromCommunityForm;
|
type UpdateForm = ModBanFromCommunityForm;
|
||||||
|
@ -252,34 +212,6 @@ impl Crud for ModBanFromCommunity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Crud for ModBan {
|
|
||||||
type InsertForm = ModBanForm;
|
|
||||||
type UpdateForm = ModBanForm;
|
|
||||||
type IdType = ModBanId;
|
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> LemmyResult<Self> {
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
|
||||||
insert_into(mod_ban::table)
|
|
||||||
.values(form)
|
|
||||||
.get_result::<Self>(conn)
|
|
||||||
.await
|
|
||||||
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn update(
|
|
||||||
pool: &mut DbPool<'_>,
|
|
||||||
from_id: Self::IdType,
|
|
||||||
form: &Self::UpdateForm,
|
|
||||||
) -> LemmyResult<Self> {
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
|
||||||
diesel::update(mod_ban::table.find(from_id))
|
|
||||||
.set(form)
|
|
||||||
.get_result::<Self>(conn)
|
|
||||||
.await
|
|
||||||
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Crud for ModChangeCommunityVisibility {
|
impl Crud for ModChangeCommunityVisibility {
|
||||||
type InsertForm = ModChangeCommunityVisibilityForm;
|
type InsertForm = ModChangeCommunityVisibilityForm;
|
||||||
type UpdateForm = ModChangeCommunityVisibilityForm;
|
type UpdateForm = ModChangeCommunityVisibilityForm;
|
||||||
|
@ -308,14 +240,14 @@ impl Crud for ModChangeCommunityVisibility {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Crud for ModAddCommunity {
|
impl Crud for ModAddToCommunity {
|
||||||
type InsertForm = ModAddCommunityForm;
|
type InsertForm = ModAddToCommunityForm;
|
||||||
type UpdateForm = ModAddCommunityForm;
|
type UpdateForm = ModAddToCommunityForm;
|
||||||
type IdType = ModAddCommunityId;
|
type IdType = ModAddToCommunityId;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> LemmyResult<Self> {
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> LemmyResult<Self> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_add_community::table)
|
insert_into(mod_add_to_community::table)
|
||||||
.values(form)
|
.values(form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
.await
|
.await
|
||||||
|
@ -328,7 +260,7 @@ impl Crud for ModAddCommunity {
|
||||||
form: &Self::UpdateForm,
|
form: &Self::UpdateForm,
|
||||||
) -> LemmyResult<Self> {
|
) -> LemmyResult<Self> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(mod_add_community::table.find(from_id))
|
diesel::update(mod_add_to_community::table.find(from_id))
|
||||||
.set(form)
|
.set(form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
.await
|
.await
|
||||||
|
@ -363,293 +295,3 @@ impl Crud for ModTransferCommunity {
|
||||||
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
|
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Crud for ModAdd {
|
|
||||||
type InsertForm = ModAddForm;
|
|
||||||
type UpdateForm = ModAddForm;
|
|
||||||
type IdType = ModAddId;
|
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> LemmyResult<Self> {
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
|
||||||
insert_into(mod_add::table)
|
|
||||||
.values(form)
|
|
||||||
.get_result::<Self>(conn)
|
|
||||||
.await
|
|
||||||
.with_lemmy_type(LemmyErrorType::CouldntCreateModlog)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn update(
|
|
||||||
pool: &mut DbPool<'_>,
|
|
||||||
from_id: Self::IdType,
|
|
||||||
form: &Self::UpdateForm,
|
|
||||||
) -> LemmyResult<Self> {
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
|
||||||
diesel::update(mod_add::table.find(from_id))
|
|
||||||
.set(form)
|
|
||||||
.get_result::<Self>(conn)
|
|
||||||
.await
|
|
||||||
.with_lemmy_type(LemmyErrorType::CouldntUpdateModlog)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
|
|
||||||
use super::*;
|
|
||||||
use crate::{
|
|
||||||
source::{
|
|
||||||
comment::{Comment, CommentInsertForm},
|
|
||||||
community::{Community, CommunityInsertForm},
|
|
||||||
instance::Instance,
|
|
||||||
person::{Person, PersonInsertForm},
|
|
||||||
post::{Post, PostInsertForm},
|
|
||||||
},
|
|
||||||
utils::build_db_pool_for_tests,
|
|
||||||
};
|
|
||||||
use lemmy_utils::error::LemmyResult;
|
|
||||||
use pretty_assertions::assert_eq;
|
|
||||||
use serial_test::serial;
|
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
#[serial]
|
|
||||||
async fn test_crud() -> LemmyResult<()> {
|
|
||||||
let pool = &build_db_pool_for_tests();
|
|
||||||
let pool = &mut pool.into();
|
|
||||||
|
|
||||||
let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()).await?;
|
|
||||||
|
|
||||||
let new_mod = PersonInsertForm::test_form(inserted_instance.id, "the mod");
|
|
||||||
|
|
||||||
let inserted_mod = Person::create(pool, &new_mod).await?;
|
|
||||||
|
|
||||||
let new_person = PersonInsertForm::test_form(inserted_instance.id, "jim2");
|
|
||||||
|
|
||||||
let inserted_person = Person::create(pool, &new_person).await?;
|
|
||||||
|
|
||||||
let new_community = CommunityInsertForm::new(
|
|
||||||
inserted_instance.id,
|
|
||||||
"mod_community".to_string(),
|
|
||||||
"nada".to_owned(),
|
|
||||||
"pubkey".to_string(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let inserted_community = Community::create(pool, &new_community).await?;
|
|
||||||
|
|
||||||
let new_post = PostInsertForm::new(
|
|
||||||
"A test post thweep".into(),
|
|
||||||
inserted_person.id,
|
|
||||||
inserted_community.id,
|
|
||||||
);
|
|
||||||
let inserted_post = Post::create(pool, &new_post).await?;
|
|
||||||
|
|
||||||
let comment_form = CommentInsertForm::new(
|
|
||||||
inserted_person.id,
|
|
||||||
inserted_post.id,
|
|
||||||
"A test comment".into(),
|
|
||||||
);
|
|
||||||
let inserted_comment = Comment::create(pool, &comment_form, None).await?;
|
|
||||||
|
|
||||||
// Now the actual tests
|
|
||||||
|
|
||||||
// remove post
|
|
||||||
let mod_remove_post_form = ModRemovePostForm {
|
|
||||||
mod_person_id: inserted_mod.id,
|
|
||||||
post_id: inserted_post.id,
|
|
||||||
reason: None,
|
|
||||||
removed: None,
|
|
||||||
};
|
|
||||||
let inserted_mod_remove_post = ModRemovePost::create(pool, &mod_remove_post_form).await?;
|
|
||||||
let read_mod_remove_post = ModRemovePost::read(pool, inserted_mod_remove_post.id).await?;
|
|
||||||
let expected_mod_remove_post = ModRemovePost {
|
|
||||||
id: inserted_mod_remove_post.id,
|
|
||||||
post_id: inserted_post.id,
|
|
||||||
mod_person_id: inserted_mod.id,
|
|
||||||
reason: None,
|
|
||||||
removed: true,
|
|
||||||
published_at: inserted_mod_remove_post.published_at,
|
|
||||||
};
|
|
||||||
|
|
||||||
// lock post
|
|
||||||
|
|
||||||
let mod_lock_post_form = ModLockPostForm {
|
|
||||||
mod_person_id: inserted_mod.id,
|
|
||||||
post_id: inserted_post.id,
|
|
||||||
locked: None,
|
|
||||||
reason: None,
|
|
||||||
};
|
|
||||||
let inserted_mod_lock_post = ModLockPost::create(pool, &mod_lock_post_form).await?;
|
|
||||||
let read_mod_lock_post = ModLockPost::read(pool, inserted_mod_lock_post.id).await?;
|
|
||||||
let expected_mod_lock_post = ModLockPost {
|
|
||||||
id: inserted_mod_lock_post.id,
|
|
||||||
post_id: inserted_post.id,
|
|
||||||
mod_person_id: inserted_mod.id,
|
|
||||||
locked: true,
|
|
||||||
reason: None,
|
|
||||||
published_at: inserted_mod_lock_post.published_at,
|
|
||||||
};
|
|
||||||
|
|
||||||
// feature post
|
|
||||||
|
|
||||||
let mod_feature_post_form = ModFeaturePostForm {
|
|
||||||
mod_person_id: inserted_mod.id,
|
|
||||||
post_id: inserted_post.id,
|
|
||||||
featured: Some(false),
|
|
||||||
is_featured_community: Some(true),
|
|
||||||
};
|
|
||||||
let inserted_mod_feature_post = ModFeaturePost::create(pool, &mod_feature_post_form).await?;
|
|
||||||
let read_mod_feature_post = ModFeaturePost::read(pool, inserted_mod_feature_post.id).await?;
|
|
||||||
let expected_mod_feature_post = ModFeaturePost {
|
|
||||||
id: inserted_mod_feature_post.id,
|
|
||||||
post_id: inserted_post.id,
|
|
||||||
mod_person_id: inserted_mod.id,
|
|
||||||
featured: false,
|
|
||||||
is_featured_community: true,
|
|
||||||
published_at: inserted_mod_feature_post.published_at,
|
|
||||||
};
|
|
||||||
|
|
||||||
// comment
|
|
||||||
|
|
||||||
let mod_remove_comment_form = ModRemoveCommentForm {
|
|
||||||
mod_person_id: inserted_mod.id,
|
|
||||||
comment_id: inserted_comment.id,
|
|
||||||
reason: None,
|
|
||||||
removed: None,
|
|
||||||
};
|
|
||||||
let inserted_mod_remove_comment =
|
|
||||||
ModRemoveComment::create(pool, &mod_remove_comment_form).await?;
|
|
||||||
let read_mod_remove_comment =
|
|
||||||
ModRemoveComment::read(pool, inserted_mod_remove_comment.id).await?;
|
|
||||||
let expected_mod_remove_comment = ModRemoveComment {
|
|
||||||
id: inserted_mod_remove_comment.id,
|
|
||||||
comment_id: inserted_comment.id,
|
|
||||||
mod_person_id: inserted_mod.id,
|
|
||||||
reason: None,
|
|
||||||
removed: true,
|
|
||||||
published_at: inserted_mod_remove_comment.published_at,
|
|
||||||
};
|
|
||||||
|
|
||||||
// community
|
|
||||||
|
|
||||||
let mod_remove_community_form = ModRemoveCommunityForm {
|
|
||||||
mod_person_id: inserted_mod.id,
|
|
||||||
community_id: inserted_community.id,
|
|
||||||
reason: None,
|
|
||||||
removed: None,
|
|
||||||
};
|
|
||||||
let inserted_mod_remove_community =
|
|
||||||
ModRemoveCommunity::create(pool, &mod_remove_community_form).await?;
|
|
||||||
let read_mod_remove_community =
|
|
||||||
ModRemoveCommunity::read(pool, inserted_mod_remove_community.id).await?;
|
|
||||||
let expected_mod_remove_community = ModRemoveCommunity {
|
|
||||||
id: inserted_mod_remove_community.id,
|
|
||||||
community_id: inserted_community.id,
|
|
||||||
mod_person_id: inserted_mod.id,
|
|
||||||
reason: None,
|
|
||||||
removed: true,
|
|
||||||
published_at: inserted_mod_remove_community.published_at,
|
|
||||||
};
|
|
||||||
|
|
||||||
// ban from community
|
|
||||||
|
|
||||||
let mod_ban_from_community_form = ModBanFromCommunityForm {
|
|
||||||
mod_person_id: inserted_mod.id,
|
|
||||||
other_person_id: inserted_person.id,
|
|
||||||
community_id: inserted_community.id,
|
|
||||||
reason: None,
|
|
||||||
banned: None,
|
|
||||||
expires_at: None,
|
|
||||||
};
|
|
||||||
let inserted_mod_ban_from_community =
|
|
||||||
ModBanFromCommunity::create(pool, &mod_ban_from_community_form).await?;
|
|
||||||
let read_mod_ban_from_community =
|
|
||||||
ModBanFromCommunity::read(pool, inserted_mod_ban_from_community.id).await?;
|
|
||||||
let expected_mod_ban_from_community = ModBanFromCommunity {
|
|
||||||
id: inserted_mod_ban_from_community.id,
|
|
||||||
community_id: inserted_community.id,
|
|
||||||
mod_person_id: inserted_mod.id,
|
|
||||||
other_person_id: inserted_person.id,
|
|
||||||
reason: None,
|
|
||||||
banned: true,
|
|
||||||
expires_at: None,
|
|
||||||
published_at: inserted_mod_ban_from_community.published_at,
|
|
||||||
};
|
|
||||||
|
|
||||||
// ban
|
|
||||||
|
|
||||||
let mod_ban_form = ModBanForm {
|
|
||||||
mod_person_id: inserted_mod.id,
|
|
||||||
other_person_id: inserted_person.id,
|
|
||||||
reason: None,
|
|
||||||
banned: None,
|
|
||||||
expires_at: None,
|
|
||||||
instance_id: inserted_instance.id,
|
|
||||||
};
|
|
||||||
let inserted_mod_ban = ModBan::create(pool, &mod_ban_form).await?;
|
|
||||||
let read_mod_ban = ModBan::read(pool, inserted_mod_ban.id).await?;
|
|
||||||
let expected_mod_ban = ModBan {
|
|
||||||
id: inserted_mod_ban.id,
|
|
||||||
mod_person_id: inserted_mod.id,
|
|
||||||
other_person_id: inserted_person.id,
|
|
||||||
reason: None,
|
|
||||||
banned: true,
|
|
||||||
expires_at: None,
|
|
||||||
published_at: inserted_mod_ban.published_at,
|
|
||||||
instance_id: inserted_instance.id,
|
|
||||||
};
|
|
||||||
|
|
||||||
// mod add community
|
|
||||||
|
|
||||||
let mod_add_community_form = ModAddCommunityForm {
|
|
||||||
mod_person_id: inserted_mod.id,
|
|
||||||
other_person_id: inserted_person.id,
|
|
||||||
community_id: inserted_community.id,
|
|
||||||
removed: None,
|
|
||||||
};
|
|
||||||
let inserted_mod_add_community = ModAddCommunity::create(pool, &mod_add_community_form).await?;
|
|
||||||
let read_mod_add_community = ModAddCommunity::read(pool, inserted_mod_add_community.id).await?;
|
|
||||||
let expected_mod_add_community = ModAddCommunity {
|
|
||||||
id: inserted_mod_add_community.id,
|
|
||||||
community_id: inserted_community.id,
|
|
||||||
mod_person_id: inserted_mod.id,
|
|
||||||
other_person_id: inserted_person.id,
|
|
||||||
removed: false,
|
|
||||||
published_at: inserted_mod_add_community.published_at,
|
|
||||||
};
|
|
||||||
|
|
||||||
// mod add
|
|
||||||
|
|
||||||
let mod_add_form = ModAddForm {
|
|
||||||
mod_person_id: inserted_mod.id,
|
|
||||||
other_person_id: inserted_person.id,
|
|
||||||
removed: None,
|
|
||||||
};
|
|
||||||
let inserted_mod_add = ModAdd::create(pool, &mod_add_form).await?;
|
|
||||||
let read_mod_add = ModAdd::read(pool, inserted_mod_add.id).await?;
|
|
||||||
let expected_mod_add = ModAdd {
|
|
||||||
id: inserted_mod_add.id,
|
|
||||||
mod_person_id: inserted_mod.id,
|
|
||||||
other_person_id: inserted_person.id,
|
|
||||||
removed: false,
|
|
||||||
published_at: inserted_mod_add.published_at,
|
|
||||||
};
|
|
||||||
|
|
||||||
Comment::delete(pool, inserted_comment.id).await?;
|
|
||||||
Post::delete(pool, inserted_post.id).await?;
|
|
||||||
Community::delete(pool, inserted_community.id).await?;
|
|
||||||
Person::delete(pool, inserted_person.id).await?;
|
|
||||||
Person::delete(pool, inserted_mod.id).await?;
|
|
||||||
Instance::delete(pool, inserted_instance.id).await?;
|
|
||||||
|
|
||||||
assert_eq!(expected_mod_remove_post, read_mod_remove_post);
|
|
||||||
assert_eq!(expected_mod_lock_post, read_mod_lock_post);
|
|
||||||
assert_eq!(expected_mod_feature_post, read_mod_feature_post);
|
|
||||||
assert_eq!(expected_mod_remove_comment, read_mod_remove_comment);
|
|
||||||
assert_eq!(expected_mod_remove_community, read_mod_remove_community);
|
|
||||||
assert_eq!(expected_mod_ban_from_community, read_mod_ban_from_community);
|
|
||||||
assert_eq!(expected_mod_ban, read_mod_ban);
|
|
||||||
assert_eq!(expected_mod_add_community, read_mod_add_community);
|
|
||||||
assert_eq!(expected_mod_add, read_mod_add);
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -95,12 +95,12 @@ pub enum ModlogActionType {
|
||||||
ModLockPost,
|
ModLockPost,
|
||||||
ModFeaturePost,
|
ModFeaturePost,
|
||||||
ModRemoveComment,
|
ModRemoveComment,
|
||||||
ModRemoveCommunity,
|
AdminRemoveCommunity,
|
||||||
ModBanFromCommunity,
|
ModBanFromCommunity,
|
||||||
ModAddCommunity,
|
ModAddToCommunity,
|
||||||
ModTransferCommunity,
|
ModTransferCommunity,
|
||||||
ModAdd,
|
AdminAdd,
|
||||||
ModBan,
|
AdminBan,
|
||||||
ModChangeCommunityVisibility,
|
ModChangeCommunityVisibility,
|
||||||
AdminPurgePerson,
|
AdminPurgePerson,
|
||||||
AdminPurgeCommunity,
|
AdminPurgeCommunity,
|
||||||
|
|
|
@ -284,7 +284,7 @@ pub struct ModRemoveCommentId(pub i32);
|
||||||
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
||||||
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
||||||
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
||||||
pub struct ModRemoveCommunityId(pub i32);
|
pub struct AdminRemoveCommunityId(pub i32);
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
|
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
|
||||||
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
||||||
|
@ -308,7 +308,7 @@ pub struct ModBanFromCommunityId(pub i32);
|
||||||
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
||||||
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
||||||
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
||||||
pub struct ModBanId(pub i32);
|
pub struct AdminBanId(pub i32);
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
|
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
|
||||||
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
||||||
|
@ -320,7 +320,7 @@ pub struct ModChangeCommunityVisibilityId(pub i32);
|
||||||
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
||||||
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
||||||
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
||||||
pub struct ModAddCommunityId(pub i32);
|
pub struct ModAddToCommunityId(pub i32);
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
|
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
|
||||||
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
||||||
|
@ -332,7 +332,7 @@ pub struct ModTransferCommunityId(pub i32);
|
||||||
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
||||||
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
||||||
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
||||||
pub struct ModAddId(pub i32);
|
pub struct AdminAddId(pub i32);
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
|
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
|
||||||
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
#[cfg_attr(feature = "full", derive(DieselNewType))]
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
use crate::newtypes::{
|
use crate::newtypes::{
|
||||||
|
AdminAddId,
|
||||||
AdminAllowInstanceId,
|
AdminAllowInstanceId,
|
||||||
|
AdminBanId,
|
||||||
AdminBlockInstanceId,
|
AdminBlockInstanceId,
|
||||||
AdminPurgeCommentId,
|
AdminPurgeCommentId,
|
||||||
AdminPurgeCommunityId,
|
AdminPurgeCommunityId,
|
||||||
AdminPurgePersonId,
|
AdminPurgePersonId,
|
||||||
AdminPurgePostId,
|
AdminPurgePostId,
|
||||||
ModAddCommunityId,
|
AdminRemoveCommunityId,
|
||||||
ModAddId,
|
ModAddToCommunityId,
|
||||||
ModBanFromCommunityId,
|
ModBanFromCommunityId,
|
||||||
ModBanId,
|
|
||||||
ModChangeCommunityVisibilityId,
|
ModChangeCommunityVisibilityId,
|
||||||
ModFeaturePostId,
|
ModFeaturePostId,
|
||||||
ModLockPostId,
|
ModLockPostId,
|
||||||
ModRemoveCommentId,
|
ModRemoveCommentId,
|
||||||
ModRemoveCommunityId,
|
|
||||||
ModRemovePostId,
|
ModRemovePostId,
|
||||||
ModTransferCommunityId,
|
ModTransferCommunityId,
|
||||||
ModlogCombinedId,
|
ModlogCombinedId,
|
||||||
|
@ -43,15 +43,15 @@ pub struct ModlogCombined {
|
||||||
pub admin_purge_community_id: Option<AdminPurgeCommunityId>,
|
pub admin_purge_community_id: Option<AdminPurgeCommunityId>,
|
||||||
pub admin_purge_person_id: Option<AdminPurgePersonId>,
|
pub admin_purge_person_id: Option<AdminPurgePersonId>,
|
||||||
pub admin_purge_post_id: Option<AdminPurgePostId>,
|
pub admin_purge_post_id: Option<AdminPurgePostId>,
|
||||||
pub mod_add_id: Option<ModAddId>,
|
pub admin_add_id: Option<AdminAddId>,
|
||||||
pub mod_add_community_id: Option<ModAddCommunityId>,
|
pub mod_add_to_community_id: Option<ModAddToCommunityId>,
|
||||||
pub mod_ban_id: Option<ModBanId>,
|
pub admin_ban_id: Option<AdminBanId>,
|
||||||
pub mod_ban_from_community_id: Option<ModBanFromCommunityId>,
|
pub mod_ban_from_community_id: Option<ModBanFromCommunityId>,
|
||||||
pub mod_feature_post_id: Option<ModFeaturePostId>,
|
pub mod_feature_post_id: Option<ModFeaturePostId>,
|
||||||
pub mod_change_community_visibility_id: Option<ModChangeCommunityVisibilityId>,
|
pub mod_change_community_visibility_id: Option<ModChangeCommunityVisibilityId>,
|
||||||
pub mod_lock_post_id: Option<ModLockPostId>,
|
pub mod_lock_post_id: Option<ModLockPostId>,
|
||||||
pub mod_remove_comment_id: Option<ModRemoveCommentId>,
|
pub mod_remove_comment_id: Option<ModRemoveCommentId>,
|
||||||
pub mod_remove_community_id: Option<ModRemoveCommunityId>,
|
pub admin_remove_community_id: Option<AdminRemoveCommunityId>,
|
||||||
pub mod_remove_post_id: Option<ModRemovePostId>,
|
pub mod_remove_post_id: Option<ModRemovePostId>,
|
||||||
pub mod_transfer_community_id: Option<ModTransferCommunityId>,
|
pub mod_transfer_community_id: Option<ModTransferCommunityId>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
use crate::newtypes::{
|
use crate::newtypes::{
|
||||||
|
AdminAddId,
|
||||||
AdminAllowInstanceId,
|
AdminAllowInstanceId,
|
||||||
|
AdminBanId,
|
||||||
AdminBlockInstanceId,
|
AdminBlockInstanceId,
|
||||||
AdminPurgeCommentId,
|
AdminPurgeCommentId,
|
||||||
AdminPurgeCommunityId,
|
AdminPurgeCommunityId,
|
||||||
AdminPurgePersonId,
|
AdminPurgePersonId,
|
||||||
AdminPurgePostId,
|
AdminPurgePostId,
|
||||||
|
AdminRemoveCommunityId,
|
||||||
CommunityId,
|
CommunityId,
|
||||||
InstanceId,
|
InstanceId,
|
||||||
PersonId,
|
PersonId,
|
||||||
|
@ -13,12 +16,15 @@ use crate::newtypes::{
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
#[cfg(feature = "full")]
|
#[cfg(feature = "full")]
|
||||||
use lemmy_db_schema_file::schema::{
|
use lemmy_db_schema_file::schema::{
|
||||||
|
admin_add,
|
||||||
admin_allow_instance,
|
admin_allow_instance,
|
||||||
|
admin_ban,
|
||||||
admin_block_instance,
|
admin_block_instance,
|
||||||
admin_purge_comment,
|
admin_purge_comment,
|
||||||
admin_purge_community,
|
admin_purge_community,
|
||||||
admin_purge_person,
|
admin_purge_person,
|
||||||
admin_purge_post,
|
admin_purge_post,
|
||||||
|
admin_remove_community,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_with::skip_serializing_none;
|
use serde_with::skip_serializing_none;
|
||||||
|
@ -181,3 +187,82 @@ pub struct AdminBlockInstanceForm {
|
||||||
pub blocked: bool,
|
pub blocked: bool,
|
||||||
pub reason: Option<String>,
|
pub reason: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[skip_serializing_none]
|
||||||
|
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||||
|
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(table_name = admin_remove_community))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
||||||
|
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
||||||
|
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
||||||
|
/// When a moderator removes a community.
|
||||||
|
pub struct AdminRemoveCommunity {
|
||||||
|
pub id: AdminRemoveCommunityId,
|
||||||
|
pub mod_person_id: PersonId,
|
||||||
|
pub community_id: CommunityId,
|
||||||
|
pub reason: Option<String>,
|
||||||
|
pub removed: bool,
|
||||||
|
pub published_at: DateTime<Utc>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(table_name = admin_remove_community))]
|
||||||
|
pub struct AdminRemoveCommunityForm {
|
||||||
|
pub mod_person_id: PersonId,
|
||||||
|
pub community_id: CommunityId,
|
||||||
|
pub reason: Option<String>,
|
||||||
|
pub removed: Option<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[skip_serializing_none]
|
||||||
|
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||||
|
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(table_name = admin_ban))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
||||||
|
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
||||||
|
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
||||||
|
/// When someone is banned from the site.
|
||||||
|
pub struct AdminBan {
|
||||||
|
pub id: AdminBanId,
|
||||||
|
pub mod_person_id: PersonId,
|
||||||
|
pub other_person_id: PersonId,
|
||||||
|
pub reason: Option<String>,
|
||||||
|
pub banned: bool,
|
||||||
|
pub expires_at: Option<DateTime<Utc>>,
|
||||||
|
pub published_at: DateTime<Utc>,
|
||||||
|
pub instance_id: InstanceId,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(table_name = admin_ban))]
|
||||||
|
pub struct AdminBanForm {
|
||||||
|
pub mod_person_id: PersonId,
|
||||||
|
pub other_person_id: PersonId,
|
||||||
|
pub reason: Option<String>,
|
||||||
|
pub banned: Option<bool>,
|
||||||
|
pub expires_at: Option<DateTime<Utc>>,
|
||||||
|
pub instance_id: InstanceId,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||||
|
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(table_name = admin_add))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
||||||
|
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
||||||
|
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
||||||
|
/// When someone is added as a site admin.
|
||||||
|
pub struct AdminAdd {
|
||||||
|
pub id: AdminAddId,
|
||||||
|
pub mod_person_id: PersonId,
|
||||||
|
pub other_person_id: PersonId,
|
||||||
|
pub removed: bool,
|
||||||
|
pub published_at: DateTime<Utc>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(table_name = admin_add))]
|
||||||
|
pub struct AdminAddForm {
|
||||||
|
pub mod_person_id: PersonId,
|
||||||
|
pub other_person_id: PersonId,
|
||||||
|
pub removed: Option<bool>,
|
||||||
|
}
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
use crate::newtypes::{
|
use crate::newtypes::{
|
||||||
CommentId,
|
CommentId,
|
||||||
CommunityId,
|
CommunityId,
|
||||||
InstanceId,
|
ModAddToCommunityId,
|
||||||
ModAddCommunityId,
|
|
||||||
ModAddId,
|
|
||||||
ModBanFromCommunityId,
|
ModBanFromCommunityId,
|
||||||
ModBanId,
|
|
||||||
ModChangeCommunityVisibilityId,
|
ModChangeCommunityVisibilityId,
|
||||||
ModFeaturePostId,
|
ModFeaturePostId,
|
||||||
ModLockPostId,
|
ModLockPostId,
|
||||||
ModRemoveCommentId,
|
ModRemoveCommentId,
|
||||||
ModRemoveCommunityId,
|
|
||||||
ModRemovePostId,
|
ModRemovePostId,
|
||||||
ModTransferCommunityId,
|
ModTransferCommunityId,
|
||||||
PersonId,
|
PersonId,
|
||||||
|
@ -20,15 +16,12 @@ use chrono::{DateTime, Utc};
|
||||||
use lemmy_db_schema_file::enums::CommunityVisibility;
|
use lemmy_db_schema_file::enums::CommunityVisibility;
|
||||||
#[cfg(feature = "full")]
|
#[cfg(feature = "full")]
|
||||||
use lemmy_db_schema_file::schema::{
|
use lemmy_db_schema_file::schema::{
|
||||||
mod_add,
|
mod_add_to_community,
|
||||||
mod_add_community,
|
|
||||||
mod_ban,
|
|
||||||
mod_ban_from_community,
|
mod_ban_from_community,
|
||||||
mod_change_community_visibility,
|
mod_change_community_visibility,
|
||||||
mod_feature_post,
|
mod_feature_post,
|
||||||
mod_lock_post,
|
mod_lock_post,
|
||||||
mod_remove_comment,
|
mod_remove_comment,
|
||||||
mod_remove_community,
|
|
||||||
mod_remove_post,
|
mod_remove_post,
|
||||||
mod_transfer_community,
|
mod_transfer_community,
|
||||||
};
|
};
|
||||||
|
@ -137,32 +130,6 @@ pub struct ModRemoveCommentForm {
|
||||||
pub removed: Option<bool>,
|
pub removed: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[skip_serializing_none]
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
|
||||||
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = mod_remove_community))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
||||||
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
|
||||||
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
|
||||||
/// When a moderator removes a community.
|
|
||||||
pub struct ModRemoveCommunity {
|
|
||||||
pub id: ModRemoveCommunityId,
|
|
||||||
pub mod_person_id: PersonId,
|
|
||||||
pub community_id: CommunityId,
|
|
||||||
pub reason: Option<String>,
|
|
||||||
pub removed: bool,
|
|
||||||
pub published_at: DateTime<Utc>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = mod_remove_community))]
|
|
||||||
pub struct ModRemoveCommunityForm {
|
|
||||||
pub mod_person_id: PersonId,
|
|
||||||
pub community_id: CommunityId,
|
|
||||||
pub reason: Option<String>,
|
|
||||||
pub removed: Option<bool>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[skip_serializing_none]
|
#[skip_serializing_none]
|
||||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||||
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable))]
|
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable))]
|
||||||
|
@ -193,25 +160,6 @@ pub struct ModBanFromCommunityForm {
|
||||||
pub expires_at: Option<DateTime<Utc>>,
|
pub expires_at: Option<DateTime<Utc>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[skip_serializing_none]
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
|
||||||
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = mod_ban))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
||||||
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
|
||||||
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
|
||||||
/// When someone is banned from the site.
|
|
||||||
pub struct ModBan {
|
|
||||||
pub id: ModBanId,
|
|
||||||
pub mod_person_id: PersonId,
|
|
||||||
pub other_person_id: PersonId,
|
|
||||||
pub reason: Option<String>,
|
|
||||||
pub banned: bool,
|
|
||||||
pub expires_at: Option<DateTime<Utc>>,
|
|
||||||
pub published_at: DateTime<Utc>,
|
|
||||||
pub instance_id: InstanceId,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = mod_change_community_visibility))]
|
#[cfg_attr(feature = "full", diesel(table_name = mod_change_community_visibility))]
|
||||||
pub struct ModChangeCommunityVisibilityForm {
|
pub struct ModChangeCommunityVisibilityForm {
|
||||||
|
@ -235,26 +183,15 @@ pub struct ModChangeCommunityVisibility {
|
||||||
pub visibility: CommunityVisibility,
|
pub visibility: CommunityVisibility,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = mod_ban))]
|
|
||||||
pub struct ModBanForm {
|
|
||||||
pub mod_person_id: PersonId,
|
|
||||||
pub other_person_id: PersonId,
|
|
||||||
pub reason: Option<String>,
|
|
||||||
pub banned: Option<bool>,
|
|
||||||
pub expires_at: Option<DateTime<Utc>>,
|
|
||||||
pub instance_id: InstanceId,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||||
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable))]
|
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable))]
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = mod_add_community))]
|
#[cfg_attr(feature = "full", diesel(table_name = mod_add_to_community))]
|
||||||
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
||||||
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
||||||
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
||||||
/// When someone is added as a community moderator.
|
/// When someone is added as a community moderator.
|
||||||
pub struct ModAddCommunity {
|
pub struct ModAddToCommunity {
|
||||||
pub id: ModAddCommunityId,
|
pub id: ModAddToCommunityId,
|
||||||
pub mod_person_id: PersonId,
|
pub mod_person_id: PersonId,
|
||||||
pub other_person_id: PersonId,
|
pub other_person_id: PersonId,
|
||||||
pub community_id: CommunityId,
|
pub community_id: CommunityId,
|
||||||
|
@ -263,8 +200,8 @@ pub struct ModAddCommunity {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = mod_add_community))]
|
#[cfg_attr(feature = "full", diesel(table_name = mod_add_to_community))]
|
||||||
pub struct ModAddCommunityForm {
|
pub struct ModAddToCommunityForm {
|
||||||
pub mod_person_id: PersonId,
|
pub mod_person_id: PersonId,
|
||||||
pub other_person_id: PersonId,
|
pub other_person_id: PersonId,
|
||||||
pub community_id: CommunityId,
|
pub community_id: CommunityId,
|
||||||
|
@ -293,26 +230,3 @@ pub struct ModTransferCommunityForm {
|
||||||
pub other_person_id: PersonId,
|
pub other_person_id: PersonId,
|
||||||
pub community_id: CommunityId,
|
pub community_id: CommunityId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
|
||||||
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = mod_add))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
||||||
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
|
||||||
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
|
||||||
/// When someone is added as a site moderator.
|
|
||||||
pub struct ModAdd {
|
|
||||||
pub id: ModAddId,
|
|
||||||
pub mod_person_id: PersonId,
|
|
||||||
pub other_person_id: PersonId,
|
|
||||||
pub removed: bool,
|
|
||||||
pub published_at: DateTime<Utc>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = mod_add))]
|
|
||||||
pub struct ModAddForm {
|
|
||||||
pub mod_person_id: PersonId,
|
|
||||||
pub other_person_id: PersonId,
|
|
||||||
pub removed: Option<bool>,
|
|
||||||
}
|
|
||||||
|
|
|
@ -58,6 +58,16 @@ pub mod sql_types {
|
||||||
pub struct VoteShowEnum;
|
pub struct VoteShowEnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diesel::table! {
|
||||||
|
admin_add (id) {
|
||||||
|
id -> Int4,
|
||||||
|
mod_person_id -> Int4,
|
||||||
|
other_person_id -> Int4,
|
||||||
|
removed -> Bool,
|
||||||
|
published_at -> Timestamptz,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
diesel::table! {
|
diesel::table! {
|
||||||
admin_allow_instance (id) {
|
admin_allow_instance (id) {
|
||||||
id -> Int4,
|
id -> Int4,
|
||||||
|
@ -69,6 +79,19 @@ diesel::table! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diesel::table! {
|
||||||
|
admin_ban (id) {
|
||||||
|
id -> Int4,
|
||||||
|
mod_person_id -> Int4,
|
||||||
|
other_person_id -> Int4,
|
||||||
|
reason -> Nullable<Text>,
|
||||||
|
banned -> Bool,
|
||||||
|
expires_at -> Nullable<Timestamptz>,
|
||||||
|
published_at -> Timestamptz,
|
||||||
|
instance_id -> Int4,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
diesel::table! {
|
diesel::table! {
|
||||||
admin_block_instance (id) {
|
admin_block_instance (id) {
|
||||||
id -> Int4,
|
id -> Int4,
|
||||||
|
@ -119,6 +142,17 @@ diesel::table! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diesel::table! {
|
||||||
|
admin_remove_community (id) {
|
||||||
|
id -> Int4,
|
||||||
|
mod_person_id -> Int4,
|
||||||
|
community_id -> Int4,
|
||||||
|
reason -> Nullable<Text>,
|
||||||
|
removed -> Bool,
|
||||||
|
published_at -> Timestamptz,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
diesel::table! {
|
diesel::table! {
|
||||||
captcha_answer (uuid) {
|
captcha_answer (uuid) {
|
||||||
uuid -> Uuid,
|
uuid -> Uuid,
|
||||||
|
@ -563,17 +597,7 @@ diesel::table! {
|
||||||
}
|
}
|
||||||
|
|
||||||
diesel::table! {
|
diesel::table! {
|
||||||
mod_add (id) {
|
mod_add_to_community (id) {
|
||||||
id -> Int4,
|
|
||||||
mod_person_id -> Int4,
|
|
||||||
other_person_id -> Int4,
|
|
||||||
removed -> Bool,
|
|
||||||
published_at -> Timestamptz,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diesel::table! {
|
|
||||||
mod_add_community (id) {
|
|
||||||
id -> Int4,
|
id -> Int4,
|
||||||
mod_person_id -> Int4,
|
mod_person_id -> Int4,
|
||||||
other_person_id -> Int4,
|
other_person_id -> Int4,
|
||||||
|
@ -583,19 +607,6 @@ diesel::table! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
diesel::table! {
|
|
||||||
mod_ban (id) {
|
|
||||||
id -> Int4,
|
|
||||||
mod_person_id -> Int4,
|
|
||||||
other_person_id -> Int4,
|
|
||||||
reason -> Nullable<Text>,
|
|
||||||
banned -> Bool,
|
|
||||||
expires_at -> Nullable<Timestamptz>,
|
|
||||||
published_at -> Timestamptz,
|
|
||||||
instance_id -> Int4,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diesel::table! {
|
diesel::table! {
|
||||||
mod_ban_from_community (id) {
|
mod_ban_from_community (id) {
|
||||||
id -> Int4,
|
id -> Int4,
|
||||||
|
@ -655,17 +666,6 @@ diesel::table! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
diesel::table! {
|
|
||||||
mod_remove_community (id) {
|
|
||||||
id -> Int4,
|
|
||||||
mod_person_id -> Int4,
|
|
||||||
community_id -> Int4,
|
|
||||||
reason -> Nullable<Text>,
|
|
||||||
removed -> Bool,
|
|
||||||
published_at -> Timestamptz,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diesel::table! {
|
diesel::table! {
|
||||||
mod_remove_post (id) {
|
mod_remove_post (id) {
|
||||||
id -> Int4,
|
id -> Int4,
|
||||||
|
@ -697,14 +697,14 @@ diesel::table! {
|
||||||
admin_purge_community_id -> Nullable<Int4>,
|
admin_purge_community_id -> Nullable<Int4>,
|
||||||
admin_purge_person_id -> Nullable<Int4>,
|
admin_purge_person_id -> Nullable<Int4>,
|
||||||
admin_purge_post_id -> Nullable<Int4>,
|
admin_purge_post_id -> Nullable<Int4>,
|
||||||
mod_add_id -> Nullable<Int4>,
|
admin_add_id -> Nullable<Int4>,
|
||||||
mod_add_community_id -> Nullable<Int4>,
|
mod_add_to_community_id -> Nullable<Int4>,
|
||||||
mod_ban_id -> Nullable<Int4>,
|
admin_ban_id -> Nullable<Int4>,
|
||||||
mod_ban_from_community_id -> Nullable<Int4>,
|
mod_ban_from_community_id -> Nullable<Int4>,
|
||||||
mod_feature_post_id -> Nullable<Int4>,
|
mod_feature_post_id -> Nullable<Int4>,
|
||||||
mod_lock_post_id -> Nullable<Int4>,
|
mod_lock_post_id -> Nullable<Int4>,
|
||||||
mod_remove_comment_id -> Nullable<Int4>,
|
mod_remove_comment_id -> Nullable<Int4>,
|
||||||
mod_remove_community_id -> Nullable<Int4>,
|
admin_remove_community_id -> Nullable<Int4>,
|
||||||
mod_remove_post_id -> Nullable<Int4>,
|
mod_remove_post_id -> Nullable<Int4>,
|
||||||
mod_transfer_community_id -> Nullable<Int4>,
|
mod_transfer_community_id -> Nullable<Int4>,
|
||||||
mod_change_community_visibility_id -> Nullable<Int4>,
|
mod_change_community_visibility_id -> Nullable<Int4>,
|
||||||
|
@ -1136,6 +1136,7 @@ diesel::table! {
|
||||||
|
|
||||||
diesel::joinable!(admin_allow_instance -> instance (instance_id));
|
diesel::joinable!(admin_allow_instance -> instance (instance_id));
|
||||||
diesel::joinable!(admin_allow_instance -> person (admin_person_id));
|
diesel::joinable!(admin_allow_instance -> person (admin_person_id));
|
||||||
|
diesel::joinable!(admin_ban -> instance (instance_id));
|
||||||
diesel::joinable!(admin_block_instance -> instance (instance_id));
|
diesel::joinable!(admin_block_instance -> instance (instance_id));
|
||||||
diesel::joinable!(admin_block_instance -> person (admin_person_id));
|
diesel::joinable!(admin_block_instance -> person (admin_person_id));
|
||||||
diesel::joinable!(admin_purge_comment -> person (admin_person_id));
|
diesel::joinable!(admin_purge_comment -> person (admin_person_id));
|
||||||
|
@ -1144,6 +1145,8 @@ diesel::joinable!(admin_purge_community -> person (admin_person_id));
|
||||||
diesel::joinable!(admin_purge_person -> person (admin_person_id));
|
diesel::joinable!(admin_purge_person -> person (admin_person_id));
|
||||||
diesel::joinable!(admin_purge_post -> community (community_id));
|
diesel::joinable!(admin_purge_post -> community (community_id));
|
||||||
diesel::joinable!(admin_purge_post -> person (admin_person_id));
|
diesel::joinable!(admin_purge_post -> person (admin_person_id));
|
||||||
|
diesel::joinable!(admin_remove_community -> community (community_id));
|
||||||
|
diesel::joinable!(admin_remove_community -> person (mod_person_id));
|
||||||
diesel::joinable!(comment -> language (language_id));
|
diesel::joinable!(comment -> language (language_id));
|
||||||
diesel::joinable!(comment -> person (creator_id));
|
diesel::joinable!(comment -> person (creator_id));
|
||||||
diesel::joinable!(comment -> post (post_id));
|
diesel::joinable!(comment -> post (post_id));
|
||||||
|
@ -1173,8 +1176,7 @@ diesel::joinable!(local_user_keyword_block -> local_user (local_user_id));
|
||||||
diesel::joinable!(local_user_language -> language (language_id));
|
diesel::joinable!(local_user_language -> language (language_id));
|
||||||
diesel::joinable!(local_user_language -> local_user (local_user_id));
|
diesel::joinable!(local_user_language -> local_user (local_user_id));
|
||||||
diesel::joinable!(login_token -> local_user (user_id));
|
diesel::joinable!(login_token -> local_user (user_id));
|
||||||
diesel::joinable!(mod_add_community -> community (community_id));
|
diesel::joinable!(mod_add_to_community -> community (community_id));
|
||||||
diesel::joinable!(mod_ban -> instance (instance_id));
|
|
||||||
diesel::joinable!(mod_ban_from_community -> community (community_id));
|
diesel::joinable!(mod_ban_from_community -> community (community_id));
|
||||||
diesel::joinable!(mod_change_community_visibility -> community (community_id));
|
diesel::joinable!(mod_change_community_visibility -> community (community_id));
|
||||||
diesel::joinable!(mod_change_community_visibility -> person (mod_person_id));
|
diesel::joinable!(mod_change_community_visibility -> person (mod_person_id));
|
||||||
|
@ -1184,26 +1186,24 @@ diesel::joinable!(mod_lock_post -> person (mod_person_id));
|
||||||
diesel::joinable!(mod_lock_post -> post (post_id));
|
diesel::joinable!(mod_lock_post -> post (post_id));
|
||||||
diesel::joinable!(mod_remove_comment -> comment (comment_id));
|
diesel::joinable!(mod_remove_comment -> comment (comment_id));
|
||||||
diesel::joinable!(mod_remove_comment -> person (mod_person_id));
|
diesel::joinable!(mod_remove_comment -> person (mod_person_id));
|
||||||
diesel::joinable!(mod_remove_community -> community (community_id));
|
|
||||||
diesel::joinable!(mod_remove_community -> person (mod_person_id));
|
|
||||||
diesel::joinable!(mod_remove_post -> person (mod_person_id));
|
diesel::joinable!(mod_remove_post -> person (mod_person_id));
|
||||||
diesel::joinable!(mod_remove_post -> post (post_id));
|
diesel::joinable!(mod_remove_post -> post (post_id));
|
||||||
diesel::joinable!(mod_transfer_community -> community (community_id));
|
diesel::joinable!(mod_transfer_community -> community (community_id));
|
||||||
|
diesel::joinable!(modlog_combined -> admin_add (admin_add_id));
|
||||||
diesel::joinable!(modlog_combined -> admin_allow_instance (admin_allow_instance_id));
|
diesel::joinable!(modlog_combined -> admin_allow_instance (admin_allow_instance_id));
|
||||||
|
diesel::joinable!(modlog_combined -> admin_ban (admin_ban_id));
|
||||||
diesel::joinable!(modlog_combined -> admin_block_instance (admin_block_instance_id));
|
diesel::joinable!(modlog_combined -> admin_block_instance (admin_block_instance_id));
|
||||||
diesel::joinable!(modlog_combined -> admin_purge_comment (admin_purge_comment_id));
|
diesel::joinable!(modlog_combined -> admin_purge_comment (admin_purge_comment_id));
|
||||||
diesel::joinable!(modlog_combined -> admin_purge_community (admin_purge_community_id));
|
diesel::joinable!(modlog_combined -> admin_purge_community (admin_purge_community_id));
|
||||||
diesel::joinable!(modlog_combined -> admin_purge_person (admin_purge_person_id));
|
diesel::joinable!(modlog_combined -> admin_purge_person (admin_purge_person_id));
|
||||||
diesel::joinable!(modlog_combined -> admin_purge_post (admin_purge_post_id));
|
diesel::joinable!(modlog_combined -> admin_purge_post (admin_purge_post_id));
|
||||||
diesel::joinable!(modlog_combined -> mod_add (mod_add_id));
|
diesel::joinable!(modlog_combined -> admin_remove_community (admin_remove_community_id));
|
||||||
diesel::joinable!(modlog_combined -> mod_add_community (mod_add_community_id));
|
diesel::joinable!(modlog_combined -> mod_add_to_community (mod_add_to_community_id));
|
||||||
diesel::joinable!(modlog_combined -> mod_ban (mod_ban_id));
|
|
||||||
diesel::joinable!(modlog_combined -> mod_ban_from_community (mod_ban_from_community_id));
|
diesel::joinable!(modlog_combined -> mod_ban_from_community (mod_ban_from_community_id));
|
||||||
diesel::joinable!(modlog_combined -> mod_change_community_visibility (mod_change_community_visibility_id));
|
diesel::joinable!(modlog_combined -> mod_change_community_visibility (mod_change_community_visibility_id));
|
||||||
diesel::joinable!(modlog_combined -> mod_feature_post (mod_feature_post_id));
|
diesel::joinable!(modlog_combined -> mod_feature_post (mod_feature_post_id));
|
||||||
diesel::joinable!(modlog_combined -> mod_lock_post (mod_lock_post_id));
|
diesel::joinable!(modlog_combined -> mod_lock_post (mod_lock_post_id));
|
||||||
diesel::joinable!(modlog_combined -> mod_remove_comment (mod_remove_comment_id));
|
diesel::joinable!(modlog_combined -> mod_remove_comment (mod_remove_comment_id));
|
||||||
diesel::joinable!(modlog_combined -> mod_remove_community (mod_remove_community_id));
|
|
||||||
diesel::joinable!(modlog_combined -> mod_remove_post (mod_remove_post_id));
|
diesel::joinable!(modlog_combined -> mod_remove_post (mod_remove_post_id));
|
||||||
diesel::joinable!(modlog_combined -> mod_transfer_community (mod_transfer_community_id));
|
diesel::joinable!(modlog_combined -> mod_transfer_community (mod_transfer_community_id));
|
||||||
diesel::joinable!(multi_community -> instance (instance_id));
|
diesel::joinable!(multi_community -> instance (instance_id));
|
||||||
|
@ -1254,12 +1254,15 @@ diesel::joinable!(site_language -> site (site_id));
|
||||||
diesel::joinable!(tag -> community (community_id));
|
diesel::joinable!(tag -> community (community_id));
|
||||||
|
|
||||||
diesel::allow_tables_to_appear_in_same_query!(
|
diesel::allow_tables_to_appear_in_same_query!(
|
||||||
|
admin_add,
|
||||||
admin_allow_instance,
|
admin_allow_instance,
|
||||||
|
admin_ban,
|
||||||
admin_block_instance,
|
admin_block_instance,
|
||||||
admin_purge_comment,
|
admin_purge_comment,
|
||||||
admin_purge_community,
|
admin_purge_community,
|
||||||
admin_purge_person,
|
admin_purge_person,
|
||||||
admin_purge_post,
|
admin_purge_post,
|
||||||
|
admin_remove_community,
|
||||||
captcha_answer,
|
captcha_answer,
|
||||||
comment,
|
comment,
|
||||||
comment_actions,
|
comment_actions,
|
||||||
|
@ -1287,15 +1290,12 @@ diesel::allow_tables_to_appear_in_same_query!(
|
||||||
local_user_keyword_block,
|
local_user_keyword_block,
|
||||||
local_user_language,
|
local_user_language,
|
||||||
login_token,
|
login_token,
|
||||||
mod_add,
|
mod_add_to_community,
|
||||||
mod_add_community,
|
|
||||||
mod_ban,
|
|
||||||
mod_ban_from_community,
|
mod_ban_from_community,
|
||||||
mod_change_community_visibility,
|
mod_change_community_visibility,
|
||||||
mod_feature_post,
|
mod_feature_post,
|
||||||
mod_lock_post,
|
mod_lock_post,
|
||||||
mod_remove_comment,
|
mod_remove_comment,
|
||||||
mod_remove_community,
|
|
||||||
mod_remove_post,
|
mod_remove_post,
|
||||||
mod_transfer_community,
|
mod_transfer_community,
|
||||||
modlog_combined,
|
modlog_combined,
|
||||||
|
|
|
@ -602,15 +602,15 @@ CALL r.create_modlog_combined_trigger ('admin_purge_comment');
|
||||||
CALL r.create_modlog_combined_trigger ('admin_purge_community');
|
CALL r.create_modlog_combined_trigger ('admin_purge_community');
|
||||||
CALL r.create_modlog_combined_trigger ('admin_purge_person');
|
CALL r.create_modlog_combined_trigger ('admin_purge_person');
|
||||||
CALL r.create_modlog_combined_trigger ('admin_purge_post');
|
CALL r.create_modlog_combined_trigger ('admin_purge_post');
|
||||||
CALL r.create_modlog_combined_trigger ('mod_add');
|
CALL r.create_modlog_combined_trigger ('admin_add');
|
||||||
CALL r.create_modlog_combined_trigger ('mod_add_community');
|
CALL r.create_modlog_combined_trigger ('mod_add_to_community');
|
||||||
CALL r.create_modlog_combined_trigger ('mod_ban');
|
CALL r.create_modlog_combined_trigger ('admin_ban');
|
||||||
CALL r.create_modlog_combined_trigger ('mod_ban_from_community');
|
CALL r.create_modlog_combined_trigger ('mod_ban_from_community');
|
||||||
CALL r.create_modlog_combined_trigger ('mod_feature_post');
|
CALL r.create_modlog_combined_trigger ('mod_feature_post');
|
||||||
CALL r.create_modlog_combined_trigger ('mod_change_community_visibility');
|
CALL r.create_modlog_combined_trigger ('mod_change_community_visibility');
|
||||||
CALL r.create_modlog_combined_trigger ('mod_lock_post');
|
CALL r.create_modlog_combined_trigger ('mod_lock_post');
|
||||||
CALL r.create_modlog_combined_trigger ('mod_remove_comment');
|
CALL r.create_modlog_combined_trigger ('mod_remove_comment');
|
||||||
CALL r.create_modlog_combined_trigger ('mod_remove_community');
|
CALL r.create_modlog_combined_trigger ('admin_remove_community');
|
||||||
CALL r.create_modlog_combined_trigger ('mod_remove_post');
|
CALL r.create_modlog_combined_trigger ('mod_remove_post');
|
||||||
CALL r.create_modlog_combined_trigger ('mod_transfer_community');
|
CALL r.create_modlog_combined_trigger ('mod_transfer_community');
|
||||||
-- Prevent using delete instead of uplete on action tables
|
-- Prevent using delete instead of uplete on action tables
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
|
AdminAddView,
|
||||||
AdminAllowInstanceView,
|
AdminAllowInstanceView,
|
||||||
|
AdminBanView,
|
||||||
AdminBlockInstanceView,
|
AdminBlockInstanceView,
|
||||||
AdminPurgeCommentView,
|
AdminPurgeCommentView,
|
||||||
AdminPurgeCommunityView,
|
AdminPurgeCommunityView,
|
||||||
AdminPurgePersonView,
|
AdminPurgePersonView,
|
||||||
AdminPurgePostView,
|
AdminPurgePostView,
|
||||||
ModAddCommunityView,
|
AdminRemoveCommunityView,
|
||||||
ModAddView,
|
ModAddToCommunityView,
|
||||||
ModBanFromCommunityView,
|
ModBanFromCommunityView,
|
||||||
ModBanView,
|
|
||||||
ModChangeCommunityVisibilityView,
|
ModChangeCommunityVisibilityView,
|
||||||
ModFeaturePostView,
|
ModFeaturePostView,
|
||||||
ModLockPostView,
|
ModLockPostView,
|
||||||
ModRemoveCommentView,
|
ModRemoveCommentView,
|
||||||
ModRemoveCommunityView,
|
|
||||||
ModRemovePostView,
|
ModRemovePostView,
|
||||||
ModTransferCommunityView,
|
ModTransferCommunityView,
|
||||||
ModlogCombinedView,
|
ModlogCombinedView,
|
||||||
|
@ -50,25 +50,25 @@ use lemmy_db_schema::{
|
||||||
use lemmy_db_schema_file::{
|
use lemmy_db_schema_file::{
|
||||||
enums::ListingType,
|
enums::ListingType,
|
||||||
schema::{
|
schema::{
|
||||||
|
admin_add,
|
||||||
admin_allow_instance,
|
admin_allow_instance,
|
||||||
|
admin_ban,
|
||||||
admin_block_instance,
|
admin_block_instance,
|
||||||
admin_purge_comment,
|
admin_purge_comment,
|
||||||
admin_purge_community,
|
admin_purge_community,
|
||||||
admin_purge_person,
|
admin_purge_person,
|
||||||
admin_purge_post,
|
admin_purge_post,
|
||||||
|
admin_remove_community,
|
||||||
comment,
|
comment,
|
||||||
community,
|
community,
|
||||||
community_actions,
|
community_actions,
|
||||||
instance,
|
instance,
|
||||||
mod_add,
|
mod_add_to_community,
|
||||||
mod_add_community,
|
|
||||||
mod_ban,
|
|
||||||
mod_ban_from_community,
|
mod_ban_from_community,
|
||||||
mod_change_community_visibility,
|
mod_change_community_visibility,
|
||||||
mod_feature_post,
|
mod_feature_post,
|
||||||
mod_lock_post,
|
mod_lock_post,
|
||||||
mod_remove_comment,
|
mod_remove_comment,
|
||||||
mod_remove_community,
|
|
||||||
mod_remove_post,
|
mod_remove_post,
|
||||||
mod_transfer_community,
|
mod_transfer_community,
|
||||||
modlog_combined,
|
modlog_combined,
|
||||||
|
@ -95,24 +95,24 @@ impl ModlogCombinedViewInternal {
|
||||||
.or(admin_purge_community::admin_person_id.eq(person::id))
|
.or(admin_purge_community::admin_person_id.eq(person::id))
|
||||||
.or(admin_purge_person::admin_person_id.eq(person::id))
|
.or(admin_purge_person::admin_person_id.eq(person::id))
|
||||||
.or(admin_purge_post::admin_person_id.eq(person::id))
|
.or(admin_purge_post::admin_person_id.eq(person::id))
|
||||||
.or(mod_add::mod_person_id.eq(person::id))
|
.or(admin_add::mod_person_id.eq(person::id))
|
||||||
.or(mod_add_community::mod_person_id.eq(person::id))
|
.or(mod_add_to_community::mod_person_id.eq(person::id))
|
||||||
.or(mod_ban::mod_person_id.eq(person::id))
|
.or(admin_ban::mod_person_id.eq(person::id))
|
||||||
.or(mod_ban_from_community::mod_person_id.eq(person::id))
|
.or(mod_ban_from_community::mod_person_id.eq(person::id))
|
||||||
.or(mod_feature_post::mod_person_id.eq(person::id))
|
.or(mod_feature_post::mod_person_id.eq(person::id))
|
||||||
.or(mod_change_community_visibility::mod_person_id.eq(person::id))
|
.or(mod_change_community_visibility::mod_person_id.eq(person::id))
|
||||||
.or(mod_lock_post::mod_person_id.eq(person::id))
|
.or(mod_lock_post::mod_person_id.eq(person::id))
|
||||||
.or(mod_remove_comment::mod_person_id.eq(person::id))
|
.or(mod_remove_comment::mod_person_id.eq(person::id))
|
||||||
.or(mod_remove_community::mod_person_id.eq(person::id))
|
.or(admin_remove_community::mod_person_id.eq(person::id))
|
||||||
.or(mod_remove_post::mod_person_id.eq(person::id))
|
.or(mod_remove_post::mod_person_id.eq(person::id))
|
||||||
.or(mod_transfer_community::mod_person_id.eq(person::id)),
|
.or(mod_transfer_community::mod_person_id.eq(person::id)),
|
||||||
);
|
);
|
||||||
|
|
||||||
let other_person_join = aliases::person1.on(
|
let other_person_join = aliases::person1.on(
|
||||||
mod_add::other_person_id
|
admin_add::other_person_id
|
||||||
.eq(other_person)
|
.eq(other_person)
|
||||||
.or(mod_add_community::other_person_id.eq(other_person))
|
.or(mod_add_to_community::other_person_id.eq(other_person))
|
||||||
.or(mod_ban::other_person_id.eq(other_person))
|
.or(admin_ban::other_person_id.eq(other_person))
|
||||||
.or(mod_ban_from_community::other_person_id.eq(other_person))
|
.or(mod_ban_from_community::other_person_id.eq(other_person))
|
||||||
// Some tables don't have the other_person_id directly, so you need to join
|
// Some tables don't have the other_person_id directly, so you need to join
|
||||||
.or(
|
.or(
|
||||||
|
@ -156,7 +156,7 @@ impl ModlogCombinedViewInternal {
|
||||||
let community_join = community::table.on(
|
let community_join = community::table.on(
|
||||||
admin_purge_post::community_id
|
admin_purge_post::community_id
|
||||||
.eq(community::id)
|
.eq(community::id)
|
||||||
.or(mod_add_community::community_id.eq(community::id))
|
.or(mod_add_to_community::community_id.eq(community::id))
|
||||||
.or(mod_ban_from_community::community_id.eq(community::id))
|
.or(mod_ban_from_community::community_id.eq(community::id))
|
||||||
.or(
|
.or(
|
||||||
mod_feature_post::id
|
mod_feature_post::id
|
||||||
|
@ -174,7 +174,7 @@ impl ModlogCombinedViewInternal {
|
||||||
.is_not_null()
|
.is_not_null()
|
||||||
.and(post::community_id.eq(community::id)),
|
.and(post::community_id.eq(community::id)),
|
||||||
)
|
)
|
||||||
.or(mod_remove_community::community_id.eq(community::id))
|
.or(admin_remove_community::community_id.eq(community::id))
|
||||||
.or(
|
.or(
|
||||||
mod_remove_post::id
|
mod_remove_post::id
|
||||||
.is_not_null()
|
.is_not_null()
|
||||||
|
@ -202,15 +202,15 @@ impl ModlogCombinedViewInternal {
|
||||||
.left_join(admin_purge_community::table)
|
.left_join(admin_purge_community::table)
|
||||||
.left_join(admin_purge_person::table)
|
.left_join(admin_purge_person::table)
|
||||||
.left_join(admin_purge_post::table)
|
.left_join(admin_purge_post::table)
|
||||||
.left_join(mod_add::table)
|
.left_join(admin_add::table)
|
||||||
.left_join(mod_add_community::table)
|
.left_join(mod_add_to_community::table)
|
||||||
.left_join(mod_ban::table)
|
.left_join(admin_ban::table)
|
||||||
.left_join(mod_ban_from_community::table)
|
.left_join(mod_ban_from_community::table)
|
||||||
.left_join(mod_feature_post::table)
|
.left_join(mod_feature_post::table)
|
||||||
.left_join(mod_change_community_visibility::table)
|
.left_join(mod_change_community_visibility::table)
|
||||||
.left_join(mod_lock_post::table)
|
.left_join(mod_lock_post::table)
|
||||||
.left_join(mod_remove_comment::table)
|
.left_join(mod_remove_comment::table)
|
||||||
.left_join(mod_remove_community::table)
|
.left_join(admin_remove_community::table)
|
||||||
.left_join(mod_remove_post::table)
|
.left_join(mod_remove_post::table)
|
||||||
.left_join(mod_transfer_community::table)
|
.left_join(mod_transfer_community::table)
|
||||||
.left_join(moderator_join)
|
.left_join(moderator_join)
|
||||||
|
@ -234,15 +234,15 @@ impl PaginationCursorBuilder for ModlogCombinedView {
|
||||||
AdminPurgeCommunity(v) => ('D', v.admin_purge_community.id.0),
|
AdminPurgeCommunity(v) => ('D', v.admin_purge_community.id.0),
|
||||||
AdminPurgePerson(v) => ('E', v.admin_purge_person.id.0),
|
AdminPurgePerson(v) => ('E', v.admin_purge_person.id.0),
|
||||||
AdminPurgePost(v) => ('F', v.admin_purge_post.id.0),
|
AdminPurgePost(v) => ('F', v.admin_purge_post.id.0),
|
||||||
ModAdd(v) => ('G', v.mod_add.id.0),
|
AdminAdd(v) => ('G', v.admin_add.id.0),
|
||||||
ModAddCommunity(v) => ('H', v.mod_add_community.id.0),
|
ModAddToCommunity(v) => ('H', v.mod_add_to_community.id.0),
|
||||||
ModBan(v) => ('I', v.mod_ban.id.0),
|
AdminBan(v) => ('I', v.admin_ban.id.0),
|
||||||
ModBanFromCommunity(v) => ('J', v.mod_ban_from_community.id.0),
|
ModBanFromCommunity(v) => ('J', v.mod_ban_from_community.id.0),
|
||||||
ModFeaturePost(v) => ('K', v.mod_feature_post.id.0),
|
ModFeaturePost(v) => ('K', v.mod_feature_post.id.0),
|
||||||
ModChangeCommunityVisibility(v) => ('L', v.mod_change_community_visibility.id.0),
|
ModChangeCommunityVisibility(v) => ('L', v.mod_change_community_visibility.id.0),
|
||||||
ModLockPost(v) => ('M', v.mod_lock_post.id.0),
|
ModLockPost(v) => ('M', v.mod_lock_post.id.0),
|
||||||
ModRemoveComment(v) => ('N', v.mod_remove_comment.id.0),
|
ModRemoveComment(v) => ('N', v.mod_remove_comment.id.0),
|
||||||
ModRemoveCommunity(v) => ('O', v.mod_remove_community.id.0),
|
AdminRemoveCommunity(v) => ('O', v.admin_remove_community.id.0),
|
||||||
ModRemovePost(v) => ('P', v.mod_remove_post.id.0),
|
ModRemovePost(v) => ('P', v.mod_remove_post.id.0),
|
||||||
ModTransferCommunity(v) => ('Q', v.mod_transfer_community.id.0),
|
ModTransferCommunity(v) => ('Q', v.mod_transfer_community.id.0),
|
||||||
};
|
};
|
||||||
|
@ -271,15 +271,15 @@ impl PaginationCursorBuilder for ModlogCombinedView {
|
||||||
'D' => query.filter(modlog_combined::admin_purge_community_id.eq(id)),
|
'D' => query.filter(modlog_combined::admin_purge_community_id.eq(id)),
|
||||||
'E' => query.filter(modlog_combined::admin_purge_person_id.eq(id)),
|
'E' => query.filter(modlog_combined::admin_purge_person_id.eq(id)),
|
||||||
'F' => query.filter(modlog_combined::admin_purge_post_id.eq(id)),
|
'F' => query.filter(modlog_combined::admin_purge_post_id.eq(id)),
|
||||||
'G' => query.filter(modlog_combined::mod_add_id.eq(id)),
|
'G' => query.filter(modlog_combined::admin_add_id.eq(id)),
|
||||||
'H' => query.filter(modlog_combined::mod_add_community_id.eq(id)),
|
'H' => query.filter(modlog_combined::mod_add_to_community_id.eq(id)),
|
||||||
'I' => query.filter(modlog_combined::mod_ban_id.eq(id)),
|
'I' => query.filter(modlog_combined::admin_ban_id.eq(id)),
|
||||||
'J' => query.filter(modlog_combined::mod_ban_from_community_id.eq(id)),
|
'J' => query.filter(modlog_combined::mod_ban_from_community_id.eq(id)),
|
||||||
'K' => query.filter(modlog_combined::mod_feature_post_id.eq(id)),
|
'K' => query.filter(modlog_combined::mod_feature_post_id.eq(id)),
|
||||||
'L' => query.filter(modlog_combined::mod_change_community_visibility_id.eq(id)),
|
'L' => query.filter(modlog_combined::mod_change_community_visibility_id.eq(id)),
|
||||||
'M' => query.filter(modlog_combined::mod_lock_post_id.eq(id)),
|
'M' => query.filter(modlog_combined::mod_lock_post_id.eq(id)),
|
||||||
'N' => query.filter(modlog_combined::mod_remove_comment_id.eq(id)),
|
'N' => query.filter(modlog_combined::mod_remove_comment_id.eq(id)),
|
||||||
'O' => query.filter(modlog_combined::mod_remove_community_id.eq(id)),
|
'O' => query.filter(modlog_combined::admin_remove_community_id.eq(id)),
|
||||||
'P' => query.filter(modlog_combined::mod_remove_post_id.eq(id)),
|
'P' => query.filter(modlog_combined::mod_remove_post_id.eq(id)),
|
||||||
'Q' => query.filter(modlog_combined::mod_transfer_community_id.eq(id)),
|
'Q' => query.filter(modlog_combined::mod_transfer_community_id.eq(id)),
|
||||||
_ => return Err(LemmyErrorType::CouldntParsePaginationToken.into()),
|
_ => return Err(LemmyErrorType::CouldntParsePaginationToken.into()),
|
||||||
|
@ -349,16 +349,18 @@ impl ModlogCombinedQuery<'_> {
|
||||||
ModLockPost => query.filter(modlog_combined::mod_lock_post_id.is_not_null()),
|
ModLockPost => query.filter(modlog_combined::mod_lock_post_id.is_not_null()),
|
||||||
ModFeaturePost => query.filter(modlog_combined::mod_feature_post_id.is_not_null()),
|
ModFeaturePost => query.filter(modlog_combined::mod_feature_post_id.is_not_null()),
|
||||||
ModRemoveComment => query.filter(modlog_combined::mod_remove_comment_id.is_not_null()),
|
ModRemoveComment => query.filter(modlog_combined::mod_remove_comment_id.is_not_null()),
|
||||||
ModRemoveCommunity => query.filter(modlog_combined::mod_remove_community_id.is_not_null()),
|
AdminRemoveCommunity => {
|
||||||
|
query.filter(modlog_combined::admin_remove_community_id.is_not_null())
|
||||||
|
}
|
||||||
ModBanFromCommunity => {
|
ModBanFromCommunity => {
|
||||||
query.filter(modlog_combined::mod_ban_from_community_id.is_not_null())
|
query.filter(modlog_combined::mod_ban_from_community_id.is_not_null())
|
||||||
}
|
}
|
||||||
ModAddCommunity => query.filter(modlog_combined::mod_add_community_id.is_not_null()),
|
ModAddToCommunity => query.filter(modlog_combined::mod_add_to_community_id.is_not_null()),
|
||||||
ModTransferCommunity => {
|
ModTransferCommunity => {
|
||||||
query.filter(modlog_combined::mod_transfer_community_id.is_not_null())
|
query.filter(modlog_combined::mod_transfer_community_id.is_not_null())
|
||||||
}
|
}
|
||||||
ModAdd => query.filter(modlog_combined::mod_add_id.is_not_null()),
|
AdminAdd => query.filter(modlog_combined::admin_add_id.is_not_null()),
|
||||||
ModBan => query.filter(modlog_combined::mod_ban_id.is_not_null()),
|
AdminBan => query.filter(modlog_combined::admin_ban_id.is_not_null()),
|
||||||
ModChangeCommunityVisibility => {
|
ModChangeCommunityVisibility => {
|
||||||
query.filter(modlog_combined::mod_change_community_visibility_id.is_not_null())
|
query.filter(modlog_combined::mod_change_community_visibility_id.is_not_null())
|
||||||
}
|
}
|
||||||
|
@ -484,26 +486,28 @@ impl InternalToCombinedView for ModlogCombinedViewInternal {
|
||||||
admin: v.moderator,
|
admin: v.moderator,
|
||||||
community,
|
community,
|
||||||
}))
|
}))
|
||||||
} else if let (Some(mod_add), Some(other_person)) = (v.mod_add, v.other_person.clone()) {
|
} else if let (Some(admin_add), Some(other_person)) = (v.admin_add, v.other_person.clone()) {
|
||||||
Some(ModlogCombinedView::ModAdd(ModAddView {
|
Some(ModlogCombinedView::AdminAdd(AdminAddView {
|
||||||
mod_add,
|
admin_add,
|
||||||
moderator: v.moderator,
|
moderator: v.moderator,
|
||||||
other_person,
|
other_person,
|
||||||
}))
|
}))
|
||||||
} else if let (Some(mod_add_community), Some(other_person), Some(community)) = (
|
} else if let (Some(mod_add_to_community), Some(other_person), Some(community)) = (
|
||||||
v.mod_add_community,
|
v.mod_add_to_community,
|
||||||
v.other_person.clone(),
|
v.other_person.clone(),
|
||||||
v.community.clone(),
|
v.community.clone(),
|
||||||
) {
|
) {
|
||||||
Some(ModlogCombinedView::ModAddCommunity(ModAddCommunityView {
|
Some(ModlogCombinedView::ModAddToCommunity(
|
||||||
mod_add_community,
|
ModAddToCommunityView {
|
||||||
moderator: v.moderator,
|
mod_add_to_community,
|
||||||
other_person,
|
moderator: v.moderator,
|
||||||
community,
|
other_person,
|
||||||
}))
|
community,
|
||||||
} else if let (Some(mod_ban), Some(other_person)) = (v.mod_ban, v.other_person.clone()) {
|
},
|
||||||
Some(ModlogCombinedView::ModBan(ModBanView {
|
))
|
||||||
mod_ban,
|
} else if let (Some(admin_ban), Some(other_person)) = (v.admin_ban, v.other_person.clone()) {
|
||||||
|
Some(ModlogCombinedView::AdminBan(AdminBanView {
|
||||||
|
admin_ban,
|
||||||
moderator: v.moderator,
|
moderator: v.moderator,
|
||||||
other_person,
|
other_person,
|
||||||
}))
|
}))
|
||||||
|
@ -577,12 +581,12 @@ impl InternalToCombinedView for ModlogCombinedViewInternal {
|
||||||
post,
|
post,
|
||||||
comment,
|
comment,
|
||||||
}))
|
}))
|
||||||
} else if let (Some(mod_remove_community), Some(community)) =
|
} else if let (Some(admin_remove_community), Some(community)) =
|
||||||
(v.mod_remove_community, v.community.clone())
|
(v.admin_remove_community, v.community.clone())
|
||||||
{
|
{
|
||||||
Some(ModlogCombinedView::ModRemoveCommunity(
|
Some(ModlogCombinedView::AdminRemoveCommunity(
|
||||||
ModRemoveCommunityView {
|
AdminRemoveCommunityView {
|
||||||
mod_remove_community,
|
admin_remove_community,
|
||||||
moderator: v.moderator,
|
moderator: v.moderator,
|
||||||
community,
|
community,
|
||||||
},
|
},
|
||||||
|
@ -622,8 +626,8 @@ impl InternalToCombinedView for ModlogCombinedViewInternal {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[expect(clippy::indexing_slicing)]
|
#[expect(clippy::indexing_slicing)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use super::*;
|
||||||
use crate::{impls::ModlogCombinedQuery, ModlogCombinedView};
|
use crate::AdminAllowInstance;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
newtypes::PersonId,
|
newtypes::PersonId,
|
||||||
source::{
|
source::{
|
||||||
|
@ -632,8 +636,11 @@ mod tests {
|
||||||
instance::Instance,
|
instance::Instance,
|
||||||
mod_log::{
|
mod_log::{
|
||||||
admin::{
|
admin::{
|
||||||
AdminAllowInstance,
|
AdminAdd,
|
||||||
|
AdminAddForm,
|
||||||
AdminAllowInstanceForm,
|
AdminAllowInstanceForm,
|
||||||
|
AdminBan,
|
||||||
|
AdminBanForm,
|
||||||
AdminBlockInstance,
|
AdminBlockInstance,
|
||||||
AdminBlockInstanceForm,
|
AdminBlockInstanceForm,
|
||||||
AdminPurgeComment,
|
AdminPurgeComment,
|
||||||
|
@ -644,14 +651,12 @@ mod tests {
|
||||||
AdminPurgePersonForm,
|
AdminPurgePersonForm,
|
||||||
AdminPurgePost,
|
AdminPurgePost,
|
||||||
AdminPurgePostForm,
|
AdminPurgePostForm,
|
||||||
|
AdminRemoveCommunity,
|
||||||
|
AdminRemoveCommunityForm,
|
||||||
},
|
},
|
||||||
moderator::{
|
moderator::{
|
||||||
ModAdd,
|
ModAddToCommunity,
|
||||||
ModAddCommunity,
|
ModAddToCommunityForm,
|
||||||
ModAddCommunityForm,
|
|
||||||
ModAddForm,
|
|
||||||
ModBan,
|
|
||||||
ModBanForm,
|
|
||||||
ModBanFromCommunity,
|
ModBanFromCommunity,
|
||||||
ModBanFromCommunityForm,
|
ModBanFromCommunityForm,
|
||||||
ModChangeCommunityVisibility,
|
ModChangeCommunityVisibility,
|
||||||
|
@ -662,8 +667,6 @@ mod tests {
|
||||||
ModLockPostForm,
|
ModLockPostForm,
|
||||||
ModRemoveComment,
|
ModRemoveComment,
|
||||||
ModRemoveCommentForm,
|
ModRemoveCommentForm,
|
||||||
ModRemoveCommunity,
|
|
||||||
ModRemoveCommunityForm,
|
|
||||||
ModRemovePost,
|
ModRemovePost,
|
||||||
ModRemovePostForm,
|
ModRemovePostForm,
|
||||||
ModTransferCommunity,
|
ModTransferCommunity,
|
||||||
|
@ -988,22 +991,22 @@ mod tests {
|
||||||
let pool = &mut pool.into();
|
let pool = &mut pool.into();
|
||||||
let data = init_data(pool).await?;
|
let data = init_data(pool).await?;
|
||||||
|
|
||||||
let form = ModAddForm {
|
let form = AdminAddForm {
|
||||||
mod_person_id: data.timmy.id,
|
mod_person_id: data.timmy.id,
|
||||||
other_person_id: data.jessica.id,
|
other_person_id: data.jessica.id,
|
||||||
removed: Some(false),
|
removed: Some(false),
|
||||||
};
|
};
|
||||||
ModAdd::create(pool, &form).await?;
|
AdminAdd::create(pool, &form).await?;
|
||||||
|
|
||||||
let form = ModAddCommunityForm {
|
let form = ModAddToCommunityForm {
|
||||||
mod_person_id: data.timmy.id,
|
mod_person_id: data.timmy.id,
|
||||||
other_person_id: data.jessica.id,
|
other_person_id: data.jessica.id,
|
||||||
community_id: data.community.id,
|
community_id: data.community.id,
|
||||||
removed: Some(false),
|
removed: Some(false),
|
||||||
};
|
};
|
||||||
ModAddCommunity::create(pool, &form).await?;
|
ModAddToCommunity::create(pool, &form).await?;
|
||||||
|
|
||||||
let form = ModBanForm {
|
let form = AdminBanForm {
|
||||||
mod_person_id: data.timmy.id,
|
mod_person_id: data.timmy.id,
|
||||||
other_person_id: data.jessica.id,
|
other_person_id: data.jessica.id,
|
||||||
banned: Some(true),
|
banned: Some(true),
|
||||||
|
@ -1011,7 +1014,7 @@ mod tests {
|
||||||
expires_at: None,
|
expires_at: None,
|
||||||
instance_id: data.instance.id,
|
instance_id: data.instance.id,
|
||||||
};
|
};
|
||||||
ModBan::create(pool, &form).await?;
|
AdminBan::create(pool, &form).await?;
|
||||||
|
|
||||||
let form = ModBanFromCommunityForm {
|
let form = ModBanFromCommunityForm {
|
||||||
mod_person_id: data.timmy.id,
|
mod_person_id: data.timmy.id,
|
||||||
|
@ -1047,13 +1050,13 @@ mod tests {
|
||||||
};
|
};
|
||||||
ModRemoveComment::create(pool, &form).await?;
|
ModRemoveComment::create(pool, &form).await?;
|
||||||
|
|
||||||
let form = ModRemoveCommunityForm {
|
let form = AdminRemoveCommunityForm {
|
||||||
mod_person_id: data.timmy.id,
|
mod_person_id: data.timmy.id,
|
||||||
community_id: data.community.id,
|
community_id: data.community.id,
|
||||||
removed: Some(true),
|
removed: Some(true),
|
||||||
reason: None,
|
reason: None,
|
||||||
};
|
};
|
||||||
ModRemoveCommunity::create(pool, &form).await?;
|
AdminRemoveCommunity::create(pool, &form).await?;
|
||||||
|
|
||||||
let form = ModRemovePostForm {
|
let form = ModRemovePostForm {
|
||||||
mod_person_id: data.timmy.id,
|
mod_person_id: data.timmy.id,
|
||||||
|
@ -1164,8 +1167,8 @@ mod tests {
|
||||||
panic!("wrong type");
|
panic!("wrong type");
|
||||||
}
|
}
|
||||||
|
|
||||||
if let ModlogCombinedView::ModRemoveCommunity(v) = &modlog[5] {
|
if let ModlogCombinedView::AdminRemoveCommunity(v) = &modlog[5] {
|
||||||
assert_eq!(data.community.id, v.mod_remove_community.community_id);
|
assert_eq!(data.community.id, v.admin_remove_community.community_id);
|
||||||
assert_eq!(data.community.id, v.community.id);
|
assert_eq!(data.community.id, v.community.id);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
data.timmy.id,
|
data.timmy.id,
|
||||||
|
@ -1231,7 +1234,7 @@ mod tests {
|
||||||
panic!("wrong type");
|
panic!("wrong type");
|
||||||
}
|
}
|
||||||
|
|
||||||
if let ModlogCombinedView::ModBan(v) = &modlog[10] {
|
if let ModlogCombinedView::AdminBan(v) = &modlog[10] {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
data.timmy.id,
|
data.timmy.id,
|
||||||
v.moderator.as_ref().map(|a| a.id).unwrap_or(PersonId(-1))
|
v.moderator.as_ref().map(|a| a.id).unwrap_or(PersonId(-1))
|
||||||
|
@ -1241,8 +1244,8 @@ mod tests {
|
||||||
panic!("wrong type");
|
panic!("wrong type");
|
||||||
}
|
}
|
||||||
|
|
||||||
if let ModlogCombinedView::ModAddCommunity(v) = &modlog[11] {
|
if let ModlogCombinedView::ModAddToCommunity(v) = &modlog[11] {
|
||||||
assert_eq!(data.community.id, v.mod_add_community.community_id);
|
assert_eq!(data.community.id, v.mod_add_to_community.community_id);
|
||||||
assert_eq!(data.community.id, v.community.id);
|
assert_eq!(data.community.id, v.community.id);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
data.timmy.id,
|
data.timmy.id,
|
||||||
|
@ -1253,7 +1256,7 @@ mod tests {
|
||||||
panic!("wrong type");
|
panic!("wrong type");
|
||||||
}
|
}
|
||||||
|
|
||||||
if let ModlogCombinedView::ModAdd(v) = &modlog[12] {
|
if let ModlogCombinedView::AdminAdd(v) = &modlog[12] {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
data.timmy.id,
|
data.timmy.id,
|
||||||
v.moderator.as_ref().map(|a| a.id).unwrap_or(PersonId(-1))
|
v.moderator.as_ref().map(|a| a.id).unwrap_or(PersonId(-1))
|
||||||
|
|
|
@ -4,23 +4,23 @@ use lemmy_db_schema::source::{
|
||||||
instance::Instance,
|
instance::Instance,
|
||||||
mod_log::{
|
mod_log::{
|
||||||
admin::{
|
admin::{
|
||||||
|
AdminAdd,
|
||||||
AdminAllowInstance,
|
AdminAllowInstance,
|
||||||
|
AdminBan,
|
||||||
AdminBlockInstance,
|
AdminBlockInstance,
|
||||||
AdminPurgeComment,
|
AdminPurgeComment,
|
||||||
AdminPurgeCommunity,
|
AdminPurgeCommunity,
|
||||||
AdminPurgePerson,
|
AdminPurgePerson,
|
||||||
AdminPurgePost,
|
AdminPurgePost,
|
||||||
|
AdminRemoveCommunity,
|
||||||
},
|
},
|
||||||
moderator::{
|
moderator::{
|
||||||
ModAdd,
|
ModAddToCommunity,
|
||||||
ModAddCommunity,
|
|
||||||
ModBan,
|
|
||||||
ModBanFromCommunity,
|
ModBanFromCommunity,
|
||||||
ModChangeCommunityVisibility,
|
ModChangeCommunityVisibility,
|
||||||
ModFeaturePost,
|
ModFeaturePost,
|
||||||
ModLockPost,
|
ModLockPost,
|
||||||
ModRemoveComment,
|
ModRemoveComment,
|
||||||
ModRemoveCommunity,
|
|
||||||
ModRemovePost,
|
ModRemovePost,
|
||||||
ModTransferCommunity,
|
ModTransferCommunity,
|
||||||
},
|
},
|
||||||
|
@ -47,8 +47,8 @@ pub mod impls;
|
||||||
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
||||||
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
||||||
/// When someone is added as a community moderator.
|
/// When someone is added as a community moderator.
|
||||||
pub struct ModAddCommunityView {
|
pub struct ModAddToCommunityView {
|
||||||
pub mod_add_community: ModAddCommunity,
|
pub mod_add_to_community: ModAddToCommunity,
|
||||||
pub moderator: Option<Person>,
|
pub moderator: Option<Person>,
|
||||||
pub community: Community,
|
pub community: Community,
|
||||||
pub other_person: Person,
|
pub other_person: Person,
|
||||||
|
@ -61,8 +61,8 @@ pub struct ModAddCommunityView {
|
||||||
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
||||||
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
||||||
/// When someone is added as a site moderator.
|
/// When someone is added as a site moderator.
|
||||||
pub struct ModAddView {
|
pub struct AdminAddView {
|
||||||
pub mod_add: ModAdd,
|
pub admin_add: AdminAdd,
|
||||||
pub moderator: Option<Person>,
|
pub moderator: Option<Person>,
|
||||||
pub other_person: Person,
|
pub other_person: Person,
|
||||||
}
|
}
|
||||||
|
@ -88,8 +88,8 @@ pub struct ModBanFromCommunityView {
|
||||||
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
||||||
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
||||||
/// When someone is banned from the site.
|
/// When someone is banned from the site.
|
||||||
pub struct ModBanView {
|
pub struct AdminBanView {
|
||||||
pub mod_ban: ModBan,
|
pub admin_ban: AdminBan,
|
||||||
pub moderator: Option<Person>,
|
pub moderator: Option<Person>,
|
||||||
pub other_person: Person,
|
pub other_person: Person,
|
||||||
}
|
}
|
||||||
|
@ -144,9 +144,9 @@ pub struct ModRemoveCommentView {
|
||||||
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
||||||
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
|
||||||
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
#[cfg_attr(feature = "ts-rs", ts(optional_fields, export))]
|
||||||
/// When a moderator removes a community.
|
/// When an admin removes a community.
|
||||||
pub struct ModRemoveCommunityView {
|
pub struct AdminRemoveCommunityView {
|
||||||
pub mod_remove_community: ModRemoveCommunity,
|
pub admin_remove_community: AdminRemoveCommunity,
|
||||||
pub moderator: Option<Person>,
|
pub moderator: Option<Person>,
|
||||||
pub community: Community,
|
pub community: Community,
|
||||||
}
|
}
|
||||||
|
@ -290,11 +290,11 @@ pub(crate) struct ModlogCombinedViewInternal {
|
||||||
#[cfg_attr(feature = "full", diesel(embed))]
|
#[cfg_attr(feature = "full", diesel(embed))]
|
||||||
pub admin_purge_post: Option<AdminPurgePost>,
|
pub admin_purge_post: Option<AdminPurgePost>,
|
||||||
#[cfg_attr(feature = "full", diesel(embed))]
|
#[cfg_attr(feature = "full", diesel(embed))]
|
||||||
pub mod_add: Option<ModAdd>,
|
pub admin_add: Option<AdminAdd>,
|
||||||
#[cfg_attr(feature = "full", diesel(embed))]
|
#[cfg_attr(feature = "full", diesel(embed))]
|
||||||
pub mod_add_community: Option<ModAddCommunity>,
|
pub mod_add_to_community: Option<ModAddToCommunity>,
|
||||||
#[cfg_attr(feature = "full", diesel(embed))]
|
#[cfg_attr(feature = "full", diesel(embed))]
|
||||||
pub mod_ban: Option<ModBan>,
|
pub admin_ban: Option<AdminBan>,
|
||||||
#[cfg_attr(feature = "full", diesel(embed))]
|
#[cfg_attr(feature = "full", diesel(embed))]
|
||||||
pub mod_ban_from_community: Option<ModBanFromCommunity>,
|
pub mod_ban_from_community: Option<ModBanFromCommunity>,
|
||||||
#[cfg_attr(feature = "full", diesel(embed))]
|
#[cfg_attr(feature = "full", diesel(embed))]
|
||||||
|
@ -306,7 +306,7 @@ pub(crate) struct ModlogCombinedViewInternal {
|
||||||
#[cfg_attr(feature = "full", diesel(embed))]
|
#[cfg_attr(feature = "full", diesel(embed))]
|
||||||
pub mod_remove_comment: Option<ModRemoveComment>,
|
pub mod_remove_comment: Option<ModRemoveComment>,
|
||||||
#[cfg_attr(feature = "full", diesel(embed))]
|
#[cfg_attr(feature = "full", diesel(embed))]
|
||||||
pub mod_remove_community: Option<ModRemoveCommunity>,
|
pub admin_remove_community: Option<AdminRemoveCommunity>,
|
||||||
#[cfg_attr(feature = "full", diesel(embed))]
|
#[cfg_attr(feature = "full", diesel(embed))]
|
||||||
pub mod_remove_post: Option<ModRemovePost>,
|
pub mod_remove_post: Option<ModRemovePost>,
|
||||||
#[cfg_attr(feature = "full", diesel(embed))]
|
#[cfg_attr(feature = "full", diesel(embed))]
|
||||||
|
@ -345,15 +345,15 @@ pub enum ModlogCombinedView {
|
||||||
AdminPurgeCommunity(AdminPurgeCommunityView),
|
AdminPurgeCommunity(AdminPurgeCommunityView),
|
||||||
AdminPurgePerson(AdminPurgePersonView),
|
AdminPurgePerson(AdminPurgePersonView),
|
||||||
AdminPurgePost(AdminPurgePostView),
|
AdminPurgePost(AdminPurgePostView),
|
||||||
ModAdd(ModAddView),
|
AdminAdd(AdminAddView),
|
||||||
ModAddCommunity(ModAddCommunityView),
|
ModAddToCommunity(ModAddToCommunityView),
|
||||||
ModBan(ModBanView),
|
AdminBan(AdminBanView),
|
||||||
ModBanFromCommunity(ModBanFromCommunityView),
|
ModBanFromCommunity(ModBanFromCommunityView),
|
||||||
ModFeaturePost(ModFeaturePostView),
|
ModFeaturePost(ModFeaturePostView),
|
||||||
ModChangeCommunityVisibility(ModChangeCommunityVisibilityView),
|
ModChangeCommunityVisibility(ModChangeCommunityVisibilityView),
|
||||||
ModLockPost(ModLockPostView),
|
ModLockPost(ModLockPostView),
|
||||||
ModRemoveComment(ModRemoveCommentView),
|
ModRemoveComment(ModRemoveCommentView),
|
||||||
ModRemoveCommunity(ModRemoveCommunityView),
|
AdminRemoveCommunity(AdminRemoveCommunityView),
|
||||||
ModRemovePost(ModRemovePostView),
|
ModRemovePost(ModRemovePostView),
|
||||||
ModTransferCommunity(ModTransferCommunityView),
|
ModTransferCommunity(ModTransferCommunityView),
|
||||||
}
|
}
|
||||||
|
|
|
@ -504,41 +504,41 @@ fn create_modlog_items(
|
||||||
&v.admin_purge_post.reason,
|
&v.admin_purge_post.reason,
|
||||||
settings,
|
settings,
|
||||||
),
|
),
|
||||||
ModlogCombinedView::ModAdd(v) => build_modlog_item(
|
ModlogCombinedView::AdminAdd(v) => build_modlog_item(
|
||||||
&v.moderator,
|
&v.moderator,
|
||||||
&v.mod_add.published_at,
|
&v.admin_add.published_at,
|
||||||
&modlog_url,
|
&modlog_url,
|
||||||
&format!(
|
&format!(
|
||||||
"{} admin {}",
|
"{} admin {}",
|
||||||
removed_added_str(v.mod_add.removed),
|
removed_added_str(v.admin_add.removed),
|
||||||
&v.other_person.name
|
&v.other_person.name
|
||||||
),
|
),
|
||||||
&None,
|
&None,
|
||||||
settings,
|
settings,
|
||||||
),
|
),
|
||||||
ModlogCombinedView::ModAddCommunity(v) => build_modlog_item(
|
ModlogCombinedView::ModAddToCommunity(v) => build_modlog_item(
|
||||||
&v.moderator,
|
&v.moderator,
|
||||||
&v.mod_add_community.published_at,
|
&v.mod_add_to_community.published_at,
|
||||||
&modlog_url,
|
&modlog_url,
|
||||||
&format!(
|
&format!(
|
||||||
"{} mod {} to /c/{}",
|
"{} mod {} to /c/{}",
|
||||||
removed_added_str(v.mod_add_community.removed),
|
removed_added_str(v.mod_add_to_community.removed),
|
||||||
&v.other_person.name,
|
&v.other_person.name,
|
||||||
&v.community.name
|
&v.community.name
|
||||||
),
|
),
|
||||||
&None,
|
&None,
|
||||||
settings,
|
settings,
|
||||||
),
|
),
|
||||||
ModlogCombinedView::ModBan(v) => build_modlog_item(
|
ModlogCombinedView::AdminBan(v) => build_modlog_item(
|
||||||
&v.moderator,
|
&v.moderator,
|
||||||
&v.mod_ban.published_at,
|
&v.admin_ban.published_at,
|
||||||
&modlog_url,
|
&modlog_url,
|
||||||
&format!(
|
&format!(
|
||||||
"{} {}",
|
"{} {}",
|
||||||
banned_unbanned_str(v.mod_ban.banned),
|
banned_unbanned_str(v.admin_ban.banned),
|
||||||
&v.other_person.name
|
&v.other_person.name
|
||||||
),
|
),
|
||||||
&v.mod_ban.reason,
|
&v.admin_ban.reason,
|
||||||
settings,
|
settings,
|
||||||
),
|
),
|
||||||
ModlogCombinedView::ModBanFromCommunity(v) => build_modlog_item(
|
ModlogCombinedView::ModBanFromCommunity(v) => build_modlog_item(
|
||||||
|
@ -609,16 +609,16 @@ fn create_modlog_items(
|
||||||
&v.mod_remove_comment.reason,
|
&v.mod_remove_comment.reason,
|
||||||
settings,
|
settings,
|
||||||
),
|
),
|
||||||
ModlogCombinedView::ModRemoveCommunity(v) => build_modlog_item(
|
ModlogCombinedView::AdminRemoveCommunity(v) => build_modlog_item(
|
||||||
&v.moderator,
|
&v.moderator,
|
||||||
&v.mod_remove_community.published_at,
|
&v.admin_remove_community.published_at,
|
||||||
&modlog_url,
|
&modlog_url,
|
||||||
&format!(
|
&format!(
|
||||||
"{} community /c/{}",
|
"{} community /c/{}",
|
||||||
removed_restored_str(v.mod_remove_community.removed),
|
removed_restored_str(v.admin_remove_community.removed),
|
||||||
&v.community.name
|
&v.community.name
|
||||||
),
|
),
|
||||||
&v.mod_remove_community.reason,
|
&v.admin_remove_community.reason,
|
||||||
settings,
|
settings,
|
||||||
),
|
),
|
||||||
ModlogCombinedView::ModRemovePost(v) => build_modlog_item(
|
ModlogCombinedView::ModRemovePost(v) => build_modlog_item(
|
||||||
|
|
16
migrations/2025-07-24-092826_modlog-rename/down.sql
Normal file
16
migrations/2025-07-24-092826_modlog-rename/down.sql
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
ALTER TABLE admin_ban RENAME TO mod_ban;
|
||||||
|
|
||||||
|
ALTER TABLE admin_add RENAME TO mod_add;
|
||||||
|
|
||||||
|
ALTER TABLE admin_remove_community RENAME TO mod_remove_community;
|
||||||
|
|
||||||
|
ALTER TABLE mod_add_to_community RENAME TO mod_add_community;
|
||||||
|
|
||||||
|
ALTER TABLE modlog_combined RENAME COLUMN admin_ban_id TO mod_ban_id;
|
||||||
|
|
||||||
|
ALTER TABLE modlog_combined RENAME COLUMN admin_add_id TO mod_add_id;
|
||||||
|
|
||||||
|
ALTER TABLE modlog_combined RENAME COLUMN admin_remove_community_id TO mod_remove_community_id;
|
||||||
|
|
||||||
|
ALTER TABLE modlog_combined RENAME COLUMN mod_add_to_community_id TO mod_add_community_id;
|
||||||
|
|
16
migrations/2025-07-24-092826_modlog-rename/up.sql
Normal file
16
migrations/2025-07-24-092826_modlog-rename/up.sql
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
ALTER TABLE mod_ban RENAME TO admin_ban;
|
||||||
|
|
||||||
|
ALTER TABLE mod_add RENAME TO admin_add;
|
||||||
|
|
||||||
|
ALTER TABLE mod_remove_community RENAME TO admin_remove_community;
|
||||||
|
|
||||||
|
ALTER TABLE mod_add_community RENAME TO mod_add_to_community;
|
||||||
|
|
||||||
|
ALTER TABLE modlog_combined RENAME COLUMN mod_ban_id TO admin_ban_id;
|
||||||
|
|
||||||
|
ALTER TABLE modlog_combined RENAME COLUMN mod_add_id TO admin_add_id;
|
||||||
|
|
||||||
|
ALTER TABLE modlog_combined RENAME COLUMN mod_remove_community_id TO admin_remove_community_id;
|
||||||
|
|
||||||
|
ALTER TABLE modlog_combined RENAME COLUMN mod_add_community_id TO mod_add_to_community_id;
|
||||||
|
|
Loading…
Reference in a new issue