mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-26 06:11:26 +00:00
move files
This commit is contained in:
parent
0670552adb
commit
aa4007f61a
35 changed files with 291 additions and 288 deletions
|
@ -10,7 +10,7 @@ use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
community::{Community, CommunityModerator, CommunityModeratorForm},
|
community::{Community, CommunityModerator, CommunityModeratorForm},
|
||||||
local_user::LocalUser,
|
local_user::LocalUser,
|
||||||
moderator::{ModAddCommunity, ModAddCommunityForm},
|
mod_log::moderator::{ModAddCommunity, ModAddCommunityForm},
|
||||||
},
|
},
|
||||||
traits::{Crud, Joinable},
|
traits::{Crud, Joinable},
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,7 +20,7 @@ use lemmy_db_schema::{
|
||||||
CommunityPersonBanForm,
|
CommunityPersonBanForm,
|
||||||
},
|
},
|
||||||
local_user::LocalUser,
|
local_user::LocalUser,
|
||||||
moderator::{ModBanFromCommunity, ModBanFromCommunityForm},
|
mod_log::moderator::{ModBanFromCommunity, ModBanFromCommunityForm},
|
||||||
},
|
},
|
||||||
traits::{Bannable, Crud, Followable},
|
traits::{Bannable, Crud, Followable},
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,7 +10,7 @@ use lemmy_api_common::{
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
community::{Community, CommunityUpdateForm},
|
community::{Community, CommunityUpdateForm},
|
||||||
moderator::{ModHideCommunity, ModHideCommunityForm},
|
mod_log::moderator::{ModHideCommunity, ModHideCommunityForm},
|
||||||
},
|
},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,7 +8,7 @@ use lemmy_api_common::{
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
community::{Community, CommunityModerator, CommunityModeratorForm},
|
community::{Community, CommunityModerator, CommunityModeratorForm},
|
||||||
moderator::{ModTransferCommunity, ModTransferCommunityForm},
|
mod_log::moderator::{ModTransferCommunity, ModTransferCommunityForm},
|
||||||
},
|
},
|
||||||
traits::{Crud, Joinable},
|
traits::{Crud, Joinable},
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,7 +19,7 @@ use lemmy_db_schema::{
|
||||||
CommunityPersonBanForm,
|
CommunityPersonBanForm,
|
||||||
},
|
},
|
||||||
local_site::LocalSite,
|
local_site::LocalSite,
|
||||||
moderator::{ModBanFromCommunity, ModBanFromCommunityForm},
|
mod_log::moderator::{ModBanFromCommunity, ModBanFromCommunityForm},
|
||||||
person::Person,
|
person::Person,
|
||||||
},
|
},
|
||||||
traits::{Bannable, Crud, Followable},
|
traits::{Bannable, Crud, Followable},
|
||||||
|
|
|
@ -7,7 +7,7 @@ use lemmy_api_common::{
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
local_user::{LocalUser, LocalUserUpdateForm},
|
local_user::{LocalUser, LocalUserUpdateForm},
|
||||||
moderator::{ModAdd, ModAddForm},
|
mod_log::moderator::{ModAdd, ModAddForm},
|
||||||
},
|
},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,7 +11,7 @@ use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
local_user::LocalUser,
|
local_user::LocalUser,
|
||||||
login_token::LoginToken,
|
login_token::LoginToken,
|
||||||
moderator::{ModBan, ModBanForm},
|
mod_log::moderator::{ModBan, ModBanForm},
|
||||||
person::{Person, PersonUpdateForm},
|
person::{Person, PersonUpdateForm},
|
||||||
},
|
},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
|
|
|
@ -10,7 +10,7 @@ use lemmy_api_common::{
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
community::Community,
|
community::Community,
|
||||||
moderator::{ModFeaturePost, ModFeaturePostForm},
|
mod_log::moderator::{ModFeaturePost, ModFeaturePostForm},
|
||||||
post::{Post, PostUpdateForm},
|
post::{Post, PostUpdateForm},
|
||||||
},
|
},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
|
|
|
@ -9,7 +9,7 @@ use lemmy_api_common::{
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
moderator::{ModLockPost, ModLockPostForm},
|
mod_log::moderator::{ModLockPost, ModLockPostForm},
|
||||||
post::{Post, PostUpdateForm},
|
post::{Post, PostUpdateForm},
|
||||||
},
|
},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
|
|
|
@ -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},
|
||||||
moderator::{ModAdd, ModAddForm},
|
mod_log::moderator::{ModAdd, ModAddForm},
|
||||||
oauth_provider::OAuthProvider,
|
oauth_provider::OAuthProvider,
|
||||||
tagline::Tagline,
|
tagline::Tagline,
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,7 +11,7 @@ use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
comment::Comment,
|
comment::Comment,
|
||||||
local_user::LocalUser,
|
local_user::LocalUser,
|
||||||
moderator::{AdminPurgeComment, AdminPurgeCommentForm},
|
mod_log::admin::{AdminPurgeComment, AdminPurgeCommentForm},
|
||||||
},
|
},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,7 +13,7 @@ use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
community::Community,
|
community::Community,
|
||||||
local_user::LocalUser,
|
local_user::LocalUser,
|
||||||
moderator::{AdminPurgeCommunity, AdminPurgeCommunityForm},
|
mod_log::admin::{AdminPurgeCommunity, AdminPurgeCommunityForm},
|
||||||
},
|
},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,7 +11,7 @@ use lemmy_api_common::{
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
local_user::LocalUser,
|
local_user::LocalUser,
|
||||||
moderator::{AdminPurgePerson, AdminPurgePersonForm},
|
mod_log::admin::{AdminPurgePerson, AdminPurgePersonForm},
|
||||||
person::{Person, PersonUpdateForm},
|
person::{Person, PersonUpdateForm},
|
||||||
},
|
},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
|
|
|
@ -11,7 +11,7 @@ use lemmy_api_common::{
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
local_user::LocalUser,
|
local_user::LocalUser,
|
||||||
moderator::{AdminPurgePost, AdminPurgePostForm},
|
mod_log::admin::{AdminPurgePost, AdminPurgePostForm},
|
||||||
post::Post,
|
post::Post,
|
||||||
},
|
},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
|
|
|
@ -23,7 +23,12 @@ use lemmy_db_schema::{
|
||||||
local_site::LocalSite,
|
local_site::LocalSite,
|
||||||
local_site_rate_limit::LocalSiteRateLimit,
|
local_site_rate_limit::LocalSiteRateLimit,
|
||||||
local_site_url_blocklist::LocalSiteUrlBlocklist,
|
local_site_url_blocklist::LocalSiteUrlBlocklist,
|
||||||
moderator::{ModRemoveComment, ModRemoveCommentForm, ModRemovePost, ModRemovePostForm},
|
mod_log::moderator::{
|
||||||
|
ModRemoveComment,
|
||||||
|
ModRemoveCommentForm,
|
||||||
|
ModRemovePost,
|
||||||
|
ModRemovePostForm,
|
||||||
|
},
|
||||||
oauth_account::OAuthAccount,
|
oauth_account::OAuthAccount,
|
||||||
password_reset_request::PasswordResetRequest,
|
password_reset_request::PasswordResetRequest,
|
||||||
person::{Person, PersonUpdateForm},
|
person::{Person, PersonUpdateForm},
|
||||||
|
|
|
@ -12,7 +12,7 @@ use lemmy_db_schema::{
|
||||||
comment::{Comment, CommentUpdateForm},
|
comment::{Comment, CommentUpdateForm},
|
||||||
comment_report::CommentReport,
|
comment_report::CommentReport,
|
||||||
local_user::LocalUser,
|
local_user::LocalUser,
|
||||||
moderator::{ModRemoveComment, ModRemoveCommentForm},
|
mod_log::moderator::{ModRemoveComment, ModRemoveCommentForm},
|
||||||
},
|
},
|
||||||
traits::{Crud, Reportable},
|
traits::{Crud, Reportable},
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,7 +10,7 @@ use lemmy_api_common::{
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
community::{Community, CommunityUpdateForm},
|
community::{Community, CommunityUpdateForm},
|
||||||
moderator::{ModRemoveCommunity, ModRemoveCommunityForm},
|
mod_log::moderator::{ModRemoveCommunity, ModRemoveCommunityForm},
|
||||||
},
|
},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,7 +11,7 @@ use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
community::Community,
|
community::Community,
|
||||||
local_user::LocalUser,
|
local_user::LocalUser,
|
||||||
moderator::{ModRemovePost, ModRemovePostForm},
|
mod_log::moderator::{ModRemovePost, ModRemovePostForm},
|
||||||
post::{Post, PostUpdateForm},
|
post::{Post, PostUpdateForm},
|
||||||
post_report::PostReport,
|
post_report::PostReport,
|
||||||
},
|
},
|
||||||
|
|
|
@ -36,7 +36,7 @@ use lemmy_db_schema::{
|
||||||
CommunityPersonBan,
|
CommunityPersonBan,
|
||||||
CommunityPersonBanForm,
|
CommunityPersonBanForm,
|
||||||
},
|
},
|
||||||
moderator::{ModBan, ModBanForm, ModBanFromCommunity, ModBanFromCommunityForm},
|
mod_log::moderator::{ModBan, ModBanForm, ModBanFromCommunity, ModBanFromCommunityForm},
|
||||||
person::{Person, PersonUpdateForm},
|
person::{Person, PersonUpdateForm},
|
||||||
},
|
},
|
||||||
traits::{Bannable, Crud, Followable},
|
traits::{Bannable, Crud, Followable},
|
||||||
|
|
|
@ -27,7 +27,7 @@ use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
activity::ActivitySendTargets,
|
activity::ActivitySendTargets,
|
||||||
community::{CommunityPersonBan, CommunityPersonBanForm},
|
community::{CommunityPersonBan, CommunityPersonBanForm},
|
||||||
moderator::{ModBan, ModBanForm, ModBanFromCommunity, ModBanFromCommunityForm},
|
mod_log::moderator::{ModBan, ModBanForm, ModBanFromCommunity, ModBanFromCommunityForm},
|
||||||
person::{Person, PersonUpdateForm},
|
person::{Person, PersonUpdateForm},
|
||||||
},
|
},
|
||||||
traits::{Bannable, Crud},
|
traits::{Bannable, Crud},
|
||||||
|
|
|
@ -31,7 +31,7 @@ use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
activity::ActivitySendTargets,
|
activity::ActivitySendTargets,
|
||||||
community::{Community, CommunityModerator, CommunityModeratorForm},
|
community::{Community, CommunityModerator, CommunityModeratorForm},
|
||||||
moderator::{ModAddCommunity, ModAddCommunityForm},
|
mod_log::moderator::{ModAddCommunity, ModAddCommunityForm},
|
||||||
person::Person,
|
person::Person,
|
||||||
post::{Post, PostUpdateForm},
|
post::{Post, PostUpdateForm},
|
||||||
},
|
},
|
||||||
|
|
|
@ -27,7 +27,7 @@ use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
activity::ActivitySendTargets,
|
activity::ActivitySendTargets,
|
||||||
community::{Community, CommunityModerator, CommunityModeratorForm},
|
community::{Community, CommunityModerator, CommunityModeratorForm},
|
||||||
moderator::{ModAddCommunity, ModAddCommunityForm},
|
mod_log::moderator::{ModAddCommunity, ModAddCommunityForm},
|
||||||
post::{Post, PostUpdateForm},
|
post::{Post, PostUpdateForm},
|
||||||
},
|
},
|
||||||
traits::{Crud, Joinable},
|
traits::{Crud, Joinable},
|
||||||
|
|
|
@ -27,7 +27,7 @@ use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
activity::ActivitySendTargets,
|
activity::ActivitySendTargets,
|
||||||
community::Community,
|
community::Community,
|
||||||
moderator::{ModLockPost, ModLockPostForm},
|
mod_log::moderator::{ModLockPost, ModLockPostForm},
|
||||||
person::Person,
|
person::Person,
|
||||||
post::{Post, PostUpdateForm},
|
post::{Post, PostUpdateForm},
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,7 +14,7 @@ use lemmy_db_schema::{
|
||||||
comment::{Comment, CommentUpdateForm},
|
comment::{Comment, CommentUpdateForm},
|
||||||
comment_report::CommentReport,
|
comment_report::CommentReport,
|
||||||
community::{Community, CommunityUpdateForm},
|
community::{Community, CommunityUpdateForm},
|
||||||
moderator::{
|
mod_log::moderator::{
|
||||||
ModRemoveComment,
|
ModRemoveComment,
|
||||||
ModRemoveCommentForm,
|
ModRemoveCommentForm,
|
||||||
ModRemoveCommunity,
|
ModRemoveCommunity,
|
||||||
|
|
|
@ -13,7 +13,7 @@ use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
comment::{Comment, CommentUpdateForm},
|
comment::{Comment, CommentUpdateForm},
|
||||||
community::{Community, CommunityUpdateForm},
|
community::{Community, CommunityUpdateForm},
|
||||||
moderator::{
|
mod_log::moderator::{
|
||||||
ModRemoveComment,
|
ModRemoveComment,
|
||||||
ModRemoveCommentForm,
|
ModRemoveCommentForm,
|
||||||
ModRemoveCommunity,
|
ModRemoveCommunity,
|
||||||
|
|
|
@ -21,7 +21,7 @@ pub mod local_site_url_blocklist;
|
||||||
pub mod local_user;
|
pub mod local_user;
|
||||||
pub mod local_user_vote_display_mode;
|
pub mod local_user_vote_display_mode;
|
||||||
pub mod login_token;
|
pub mod login_token;
|
||||||
pub mod moderator;
|
pub mod mod_log;
|
||||||
pub mod oauth_account;
|
pub mod oauth_account;
|
||||||
pub mod oauth_provider;
|
pub mod oauth_provider;
|
||||||
pub mod password_reset_request;
|
pub mod password_reset_request;
|
||||||
|
|
132
crates/db_schema/src/impls/mod_log/admin.rs
Normal file
132
crates/db_schema/src/impls/mod_log/admin.rs
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
use crate::{
|
||||||
|
source::mod_log::admin::{
|
||||||
|
AdminPurgeComment,
|
||||||
|
AdminPurgeCommentForm,
|
||||||
|
AdminPurgeCommunity,
|
||||||
|
AdminPurgeCommunityForm,
|
||||||
|
AdminPurgePerson,
|
||||||
|
AdminPurgePersonForm,
|
||||||
|
AdminPurgePost,
|
||||||
|
AdminPurgePostForm,
|
||||||
|
},
|
||||||
|
traits::Crud,
|
||||||
|
utils::{get_conn, DbPool},
|
||||||
|
};
|
||||||
|
use diesel::{dsl::insert_into, result::Error, QueryDsl};
|
||||||
|
use diesel_async::RunQueryDsl;
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl Crud for AdminPurgePerson {
|
||||||
|
type InsertForm = AdminPurgePersonForm;
|
||||||
|
type UpdateForm = AdminPurgePersonForm;
|
||||||
|
type IdType = i32;
|
||||||
|
|
||||||
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||||
|
use crate::schema::admin_purge_person::dsl::admin_purge_person;
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
insert_into(admin_purge_person)
|
||||||
|
.values(form)
|
||||||
|
.get_result::<Self>(conn)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update(
|
||||||
|
pool: &mut DbPool<'_>,
|
||||||
|
from_id: i32,
|
||||||
|
form: &Self::InsertForm,
|
||||||
|
) -> Result<Self, Error> {
|
||||||
|
use crate::schema::admin_purge_person::dsl::admin_purge_person;
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
diesel::update(admin_purge_person.find(from_id))
|
||||||
|
.set(form)
|
||||||
|
.get_result::<Self>(conn)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl Crud for AdminPurgeCommunity {
|
||||||
|
type InsertForm = AdminPurgeCommunityForm;
|
||||||
|
type UpdateForm = AdminPurgeCommunityForm;
|
||||||
|
type IdType = i32;
|
||||||
|
|
||||||
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||||
|
use crate::schema::admin_purge_community::dsl::admin_purge_community;
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
insert_into(admin_purge_community)
|
||||||
|
.values(form)
|
||||||
|
.get_result::<Self>(conn)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update(
|
||||||
|
pool: &mut DbPool<'_>,
|
||||||
|
from_id: i32,
|
||||||
|
form: &Self::InsertForm,
|
||||||
|
) -> Result<Self, Error> {
|
||||||
|
use crate::schema::admin_purge_community::dsl::admin_purge_community;
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
diesel::update(admin_purge_community.find(from_id))
|
||||||
|
.set(form)
|
||||||
|
.get_result::<Self>(conn)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl Crud for AdminPurgePost {
|
||||||
|
type InsertForm = AdminPurgePostForm;
|
||||||
|
type UpdateForm = AdminPurgePostForm;
|
||||||
|
type IdType = i32;
|
||||||
|
|
||||||
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||||
|
use crate::schema::admin_purge_post::dsl::admin_purge_post;
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
insert_into(admin_purge_post)
|
||||||
|
.values(form)
|
||||||
|
.get_result::<Self>(conn)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update(
|
||||||
|
pool: &mut DbPool<'_>,
|
||||||
|
from_id: i32,
|
||||||
|
form: &Self::InsertForm,
|
||||||
|
) -> Result<Self, Error> {
|
||||||
|
use crate::schema::admin_purge_post::dsl::admin_purge_post;
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
diesel::update(admin_purge_post.find(from_id))
|
||||||
|
.set(form)
|
||||||
|
.get_result::<Self>(conn)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl Crud for AdminPurgeComment {
|
||||||
|
type InsertForm = AdminPurgeCommentForm;
|
||||||
|
type UpdateForm = AdminPurgeCommentForm;
|
||||||
|
type IdType = i32;
|
||||||
|
|
||||||
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||||
|
use crate::schema::admin_purge_comment::dsl::admin_purge_comment;
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
insert_into(admin_purge_comment)
|
||||||
|
.values(form)
|
||||||
|
.get_result::<Self>(conn)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update(
|
||||||
|
pool: &mut DbPool<'_>,
|
||||||
|
from_id: i32,
|
||||||
|
form: &Self::InsertForm,
|
||||||
|
) -> Result<Self, Error> {
|
||||||
|
use crate::schema::admin_purge_comment::dsl::admin_purge_comment;
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
diesel::update(admin_purge_comment.find(from_id))
|
||||||
|
.set(form)
|
||||||
|
.get_result::<Self>(conn)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
}
|
2
crates/db_schema/src/impls/mod_log/mod.rs
Normal file
2
crates/db_schema/src/impls/mod_log/mod.rs
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
pub mod admin;
|
||||||
|
pub mod moderator;
|
|
@ -1,13 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
source::moderator::{
|
source::mod_log::moderator::{
|
||||||
AdminPurgeComment,
|
|
||||||
AdminPurgeCommentForm,
|
|
||||||
AdminPurgeCommunity,
|
|
||||||
AdminPurgeCommunityForm,
|
|
||||||
AdminPurgePerson,
|
|
||||||
AdminPurgePersonForm,
|
|
||||||
AdminPurgePost,
|
|
||||||
AdminPurgePostForm,
|
|
||||||
ModAdd,
|
ModAdd,
|
||||||
ModAddCommunity,
|
ModAddCommunity,
|
||||||
ModAddCommunityForm,
|
ModAddCommunityForm,
|
||||||
|
@ -376,157 +368,20 @@ impl Crud for ModAdd {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl Crud for AdminPurgePerson {
|
|
||||||
type InsertForm = AdminPurgePersonForm;
|
|
||||||
type UpdateForm = AdminPurgePersonForm;
|
|
||||||
type IdType = i32;
|
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
|
||||||
use crate::schema::admin_purge_person::dsl::admin_purge_person;
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
|
||||||
insert_into(admin_purge_person)
|
|
||||||
.values(form)
|
|
||||||
.get_result::<Self>(conn)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn update(
|
|
||||||
pool: &mut DbPool<'_>,
|
|
||||||
from_id: i32,
|
|
||||||
form: &Self::InsertForm,
|
|
||||||
) -> Result<Self, Error> {
|
|
||||||
use crate::schema::admin_purge_person::dsl::admin_purge_person;
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
|
||||||
diesel::update(admin_purge_person.find(from_id))
|
|
||||||
.set(form)
|
|
||||||
.get_result::<Self>(conn)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl Crud for AdminPurgeCommunity {
|
|
||||||
type InsertForm = AdminPurgeCommunityForm;
|
|
||||||
type UpdateForm = AdminPurgeCommunityForm;
|
|
||||||
type IdType = i32;
|
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
|
||||||
use crate::schema::admin_purge_community::dsl::admin_purge_community;
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
|
||||||
insert_into(admin_purge_community)
|
|
||||||
.values(form)
|
|
||||||
.get_result::<Self>(conn)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn update(
|
|
||||||
pool: &mut DbPool<'_>,
|
|
||||||
from_id: i32,
|
|
||||||
form: &Self::InsertForm,
|
|
||||||
) -> Result<Self, Error> {
|
|
||||||
use crate::schema::admin_purge_community::dsl::admin_purge_community;
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
|
||||||
diesel::update(admin_purge_community.find(from_id))
|
|
||||||
.set(form)
|
|
||||||
.get_result::<Self>(conn)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl Crud for AdminPurgePost {
|
|
||||||
type InsertForm = AdminPurgePostForm;
|
|
||||||
type UpdateForm = AdminPurgePostForm;
|
|
||||||
type IdType = i32;
|
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
|
||||||
use crate::schema::admin_purge_post::dsl::admin_purge_post;
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
|
||||||
insert_into(admin_purge_post)
|
|
||||||
.values(form)
|
|
||||||
.get_result::<Self>(conn)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn update(
|
|
||||||
pool: &mut DbPool<'_>,
|
|
||||||
from_id: i32,
|
|
||||||
form: &Self::InsertForm,
|
|
||||||
) -> Result<Self, Error> {
|
|
||||||
use crate::schema::admin_purge_post::dsl::admin_purge_post;
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
|
||||||
diesel::update(admin_purge_post.find(from_id))
|
|
||||||
.set(form)
|
|
||||||
.get_result::<Self>(conn)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl Crud for AdminPurgeComment {
|
|
||||||
type InsertForm = AdminPurgeCommentForm;
|
|
||||||
type UpdateForm = AdminPurgeCommentForm;
|
|
||||||
type IdType = i32;
|
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
|
||||||
use crate::schema::admin_purge_comment::dsl::admin_purge_comment;
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
|
||||||
insert_into(admin_purge_comment)
|
|
||||||
.values(form)
|
|
||||||
.get_result::<Self>(conn)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn update(
|
|
||||||
pool: &mut DbPool<'_>,
|
|
||||||
from_id: i32,
|
|
||||||
form: &Self::InsertForm,
|
|
||||||
) -> Result<Self, Error> {
|
|
||||||
use crate::schema::admin_purge_comment::dsl::admin_purge_comment;
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
|
||||||
diesel::update(admin_purge_comment.find(from_id))
|
|
||||||
.set(form)
|
|
||||||
.get_result::<Self>(conn)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
|
use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
source::{
|
source::{
|
||||||
comment::{Comment, CommentInsertForm},
|
comment::{Comment, CommentInsertForm},
|
||||||
community::{Community, CommunityInsertForm},
|
community::{Community, CommunityInsertForm},
|
||||||
instance::Instance,
|
instance::Instance,
|
||||||
moderator::{
|
|
||||||
ModAdd,
|
|
||||||
ModAddCommunity,
|
|
||||||
ModAddCommunityForm,
|
|
||||||
ModAddForm,
|
|
||||||
ModBan,
|
|
||||||
ModBanForm,
|
|
||||||
ModBanFromCommunity,
|
|
||||||
ModBanFromCommunityForm,
|
|
||||||
ModFeaturePost,
|
|
||||||
ModFeaturePostForm,
|
|
||||||
ModLockPost,
|
|
||||||
ModLockPostForm,
|
|
||||||
ModRemoveComment,
|
|
||||||
ModRemoveCommentForm,
|
|
||||||
ModRemoveCommunity,
|
|
||||||
ModRemoveCommunityForm,
|
|
||||||
ModRemovePost,
|
|
||||||
ModRemovePostForm,
|
|
||||||
},
|
|
||||||
person::{Person, PersonInsertForm},
|
person::{Person, PersonInsertForm},
|
||||||
post::{Post, PostInsertForm},
|
post::{Post, PostInsertForm},
|
||||||
},
|
},
|
||||||
traits::Crud,
|
|
||||||
utils::build_db_pool_for_tests,
|
utils::build_db_pool_for_tests,
|
||||||
};
|
};
|
||||||
use diesel::result::Error;
|
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
|
@ -26,7 +26,7 @@ pub mod local_site_url_blocklist;
|
||||||
pub mod local_user;
|
pub mod local_user;
|
||||||
pub mod local_user_vote_display_mode;
|
pub mod local_user_vote_display_mode;
|
||||||
pub mod login_token;
|
pub mod login_token;
|
||||||
pub mod moderator;
|
pub mod mod_log;
|
||||||
pub mod oauth_account;
|
pub mod oauth_account;
|
||||||
pub mod oauth_provider;
|
pub mod oauth_provider;
|
||||||
pub mod password_reset_request;
|
pub mod password_reset_request;
|
||||||
|
|
105
crates/db_schema/src/source/mod_log/admin.rs
Normal file
105
crates/db_schema/src/source/mod_log/admin.rs
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
use crate::newtypes::{CommunityId, PersonId, PostId};
|
||||||
|
#[cfg(feature = "full")]
|
||||||
|
use crate::schema::{
|
||||||
|
admin_purge_comment,
|
||||||
|
admin_purge_community,
|
||||||
|
admin_purge_person,
|
||||||
|
admin_purge_post,
|
||||||
|
};
|
||||||
|
use chrono::{DateTime, Utc};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use serde_with::skip_serializing_none;
|
||||||
|
#[cfg(feature = "full")]
|
||||||
|
use ts_rs::TS;
|
||||||
|
|
||||||
|
#[skip_serializing_none]
|
||||||
|
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||||
|
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable, TS))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(table_name = admin_purge_person))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
||||||
|
#[cfg_attr(feature = "full", ts(export))]
|
||||||
|
/// When an admin purges a person.
|
||||||
|
pub struct AdminPurgePerson {
|
||||||
|
pub id: i32,
|
||||||
|
pub admin_person_id: PersonId,
|
||||||
|
#[cfg_attr(feature = "full", ts(optional))]
|
||||||
|
pub reason: Option<String>,
|
||||||
|
pub when_: DateTime<Utc>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(table_name = admin_purge_person))]
|
||||||
|
pub struct AdminPurgePersonForm {
|
||||||
|
pub admin_person_id: PersonId,
|
||||||
|
pub reason: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[skip_serializing_none]
|
||||||
|
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||||
|
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable, TS))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(table_name = admin_purge_community))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
||||||
|
#[cfg_attr(feature = "full", ts(export))]
|
||||||
|
/// When an admin purges a community.
|
||||||
|
pub struct AdminPurgeCommunity {
|
||||||
|
pub id: i32,
|
||||||
|
pub admin_person_id: PersonId,
|
||||||
|
#[cfg_attr(feature = "full", ts(optional))]
|
||||||
|
pub reason: Option<String>,
|
||||||
|
pub when_: DateTime<Utc>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(table_name = admin_purge_community))]
|
||||||
|
pub struct AdminPurgeCommunityForm {
|
||||||
|
pub admin_person_id: PersonId,
|
||||||
|
pub reason: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[skip_serializing_none]
|
||||||
|
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||||
|
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable, TS))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(table_name = admin_purge_post))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
||||||
|
#[cfg_attr(feature = "full", ts(export))]
|
||||||
|
/// When an admin purges a post.
|
||||||
|
pub struct AdminPurgePost {
|
||||||
|
pub id: i32,
|
||||||
|
pub admin_person_id: PersonId,
|
||||||
|
pub community_id: CommunityId,
|
||||||
|
#[cfg_attr(feature = "full", ts(optional))]
|
||||||
|
pub reason: Option<String>,
|
||||||
|
pub when_: DateTime<Utc>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(table_name = admin_purge_post))]
|
||||||
|
pub struct AdminPurgePostForm {
|
||||||
|
pub admin_person_id: PersonId,
|
||||||
|
pub community_id: CommunityId,
|
||||||
|
pub reason: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[skip_serializing_none]
|
||||||
|
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||||
|
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable, TS))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(table_name = admin_purge_comment))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
||||||
|
#[cfg_attr(feature = "full", ts(export))]
|
||||||
|
/// When an admin purges a comment.
|
||||||
|
pub struct AdminPurgeComment {
|
||||||
|
pub id: i32,
|
||||||
|
pub admin_person_id: PersonId,
|
||||||
|
pub post_id: PostId,
|
||||||
|
#[cfg_attr(feature = "full", ts(optional))]
|
||||||
|
pub reason: Option<String>,
|
||||||
|
pub when_: DateTime<Utc>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||||
|
#[cfg_attr(feature = "full", diesel(table_name = admin_purge_comment))]
|
||||||
|
pub struct AdminPurgeCommentForm {
|
||||||
|
pub admin_person_id: PersonId,
|
||||||
|
pub post_id: PostId,
|
||||||
|
pub reason: Option<String>,
|
||||||
|
}
|
2
crates/db_schema/src/source/mod_log/mod.rs
Normal file
2
crates/db_schema/src/source/mod_log/mod.rs
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
pub mod admin;
|
||||||
|
pub mod moderator;
|
|
@ -1,10 +1,6 @@
|
||||||
use crate::newtypes::{CommentId, CommunityId, PersonId, PostId};
|
use crate::newtypes::{CommentId, CommunityId, PersonId, PostId};
|
||||||
#[cfg(feature = "full")]
|
#[cfg(feature = "full")]
|
||||||
use crate::schema::{
|
use crate::schema::{
|
||||||
admin_purge_comment,
|
|
||||||
admin_purge_community,
|
|
||||||
admin_purge_person,
|
|
||||||
admin_purge_post,
|
|
||||||
mod_add,
|
mod_add,
|
||||||
mod_add_community,
|
mod_add_community,
|
||||||
mod_ban,
|
mod_ban,
|
||||||
|
@ -300,95 +296,3 @@ pub struct ModAddForm {
|
||||||
pub other_person_id: PersonId,
|
pub other_person_id: PersonId,
|
||||||
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, TS))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = admin_purge_person))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
||||||
#[cfg_attr(feature = "full", ts(export))]
|
|
||||||
/// When an admin purges a person.
|
|
||||||
pub struct AdminPurgePerson {
|
|
||||||
pub id: i32,
|
|
||||||
pub admin_person_id: PersonId,
|
|
||||||
#[cfg_attr(feature = "full", ts(optional))]
|
|
||||||
pub reason: Option<String>,
|
|
||||||
pub when_: DateTime<Utc>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = admin_purge_person))]
|
|
||||||
pub struct AdminPurgePersonForm {
|
|
||||||
pub admin_person_id: PersonId,
|
|
||||||
pub reason: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[skip_serializing_none]
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
|
||||||
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable, TS))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = admin_purge_community))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
||||||
#[cfg_attr(feature = "full", ts(export))]
|
|
||||||
/// When an admin purges a community.
|
|
||||||
pub struct AdminPurgeCommunity {
|
|
||||||
pub id: i32,
|
|
||||||
pub admin_person_id: PersonId,
|
|
||||||
#[cfg_attr(feature = "full", ts(optional))]
|
|
||||||
pub reason: Option<String>,
|
|
||||||
pub when_: DateTime<Utc>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = admin_purge_community))]
|
|
||||||
pub struct AdminPurgeCommunityForm {
|
|
||||||
pub admin_person_id: PersonId,
|
|
||||||
pub reason: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[skip_serializing_none]
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
|
||||||
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable, TS))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = admin_purge_post))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
||||||
#[cfg_attr(feature = "full", ts(export))]
|
|
||||||
/// When an admin purges a post.
|
|
||||||
pub struct AdminPurgePost {
|
|
||||||
pub id: i32,
|
|
||||||
pub admin_person_id: PersonId,
|
|
||||||
pub community_id: CommunityId,
|
|
||||||
#[cfg_attr(feature = "full", ts(optional))]
|
|
||||||
pub reason: Option<String>,
|
|
||||||
pub when_: DateTime<Utc>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = admin_purge_post))]
|
|
||||||
pub struct AdminPurgePostForm {
|
|
||||||
pub admin_person_id: PersonId,
|
|
||||||
pub community_id: CommunityId,
|
|
||||||
pub reason: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[skip_serializing_none]
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
|
||||||
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable, TS))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = admin_purge_comment))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
||||||
#[cfg_attr(feature = "full", ts(export))]
|
|
||||||
/// When an admin purges a comment.
|
|
||||||
pub struct AdminPurgeComment {
|
|
||||||
pub id: i32,
|
|
||||||
pub admin_person_id: PersonId,
|
|
||||||
pub post_id: PostId,
|
|
||||||
#[cfg_attr(feature = "full", ts(optional))]
|
|
||||||
pub reason: Option<String>,
|
|
||||||
pub when_: DateTime<Utc>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = admin_purge_comment))]
|
|
||||||
pub struct AdminPurgeCommentForm {
|
|
||||||
pub admin_person_id: PersonId,
|
|
||||||
pub post_id: PostId,
|
|
||||||
pub reason: Option<String>,
|
|
||||||
}
|
|
|
@ -8,11 +8,9 @@ use lemmy_db_schema::{
|
||||||
federation_allowlist::AdminAllowInstance,
|
federation_allowlist::AdminAllowInstance,
|
||||||
federation_blocklist::AdminBlockInstance,
|
federation_blocklist::AdminBlockInstance,
|
||||||
instance::Instance,
|
instance::Instance,
|
||||||
|
mod_log::{
|
||||||
|
admin::{AdminPurgeComment, AdminPurgeCommunity, AdminPurgePerson, AdminPurgePost},
|
||||||
moderator::{
|
moderator::{
|
||||||
AdminPurgeComment,
|
|
||||||
AdminPurgeCommunity,
|
|
||||||
AdminPurgePerson,
|
|
||||||
AdminPurgePost,
|
|
||||||
ModAdd,
|
ModAdd,
|
||||||
ModAddCommunity,
|
ModAddCommunity,
|
||||||
ModBan,
|
ModBan,
|
||||||
|
@ -25,6 +23,7 @@ use lemmy_db_schema::{
|
||||||
ModRemovePost,
|
ModRemovePost,
|
||||||
ModTransferCommunity,
|
ModTransferCommunity,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
person::Person,
|
person::Person,
|
||||||
post::Post,
|
post::Post,
|
||||||
},
|
},
|
||||||
|
|
|
@ -442,8 +442,7 @@ async fn update_banned_when_expired(pool: &mut DbPool<'_>) {
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
diesel::delete(
|
diesel::delete(
|
||||||
federation_blocklist::table
|
federation_blocklist::table.filter(federation_blocklist::expires.lt(now().nullable())),
|
||||||
.filter(federation_blocklist::expires.lt(now().nullable())),
|
|
||||||
)
|
)
|
||||||
.execute(&mut conn)
|
.execute(&mut conn)
|
||||||
.await
|
.await
|
||||||
|
|
Loading…
Reference in a new issue