2022-11-09 10:05:00 +00:00
|
|
|
use crate::{
|
2022-11-19 04:33:54 +00:00
|
|
|
source::moderator::{
|
|
|
|
AdminPurgeComment,
|
|
|
|
AdminPurgeCommentForm,
|
|
|
|
AdminPurgeCommunity,
|
|
|
|
AdminPurgeCommunityForm,
|
|
|
|
AdminPurgePerson,
|
|
|
|
AdminPurgePersonForm,
|
|
|
|
AdminPurgePost,
|
|
|
|
AdminPurgePostForm,
|
|
|
|
ModAdd,
|
|
|
|
ModAddCommunity,
|
|
|
|
ModAddCommunityForm,
|
|
|
|
ModAddForm,
|
|
|
|
ModBan,
|
|
|
|
ModBanForm,
|
|
|
|
ModBanFromCommunity,
|
|
|
|
ModBanFromCommunityForm,
|
2022-12-12 11:17:10 +00:00
|
|
|
ModFeaturePost,
|
|
|
|
ModFeaturePostForm,
|
2022-11-19 04:33:54 +00:00
|
|
|
ModHideCommunity,
|
|
|
|
ModHideCommunityForm,
|
|
|
|
ModLockPost,
|
|
|
|
ModLockPostForm,
|
|
|
|
ModRemoveComment,
|
|
|
|
ModRemoveCommentForm,
|
|
|
|
ModRemoveCommunity,
|
|
|
|
ModRemoveCommunityForm,
|
|
|
|
ModRemovePost,
|
|
|
|
ModRemovePostForm,
|
|
|
|
ModTransferCommunity,
|
|
|
|
ModTransferCommunityForm,
|
|
|
|
},
|
2022-11-09 10:05:00 +00:00
|
|
|
traits::Crud,
|
|
|
|
utils::{get_conn, DbPool},
|
|
|
|
};
|
2022-11-19 04:33:54 +00:00
|
|
|
use diesel::{dsl::insert_into, result::Error, QueryDsl};
|
2022-11-09 10:05:00 +00:00
|
|
|
use diesel_async::RunQueryDsl;
|
|
|
|
|
|
|
|
#[async_trait]
|
2021-08-17 18:04:58 +00:00
|
|
|
impl Crud for ModRemovePost {
|
2022-10-27 09:24:07 +00:00
|
|
|
type InsertForm = ModRemovePostForm;
|
|
|
|
type UpdateForm = ModRemovePostForm;
|
2021-08-17 18:04:58 +00:00
|
|
|
type IdType = i32;
|
2019-04-15 23:12:06 +00:00
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn create(pool: &mut DbPool<'_>, form: &ModRemovePostForm) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::mod_remove_post::dsl::mod_remove_post;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2019-09-07 15:35:05 +00:00
|
|
|
insert_into(mod_remove_post)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2019-04-15 23:12:06 +00:00
|
|
|
}
|
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn update(
|
|
|
|
pool: &mut DbPool<'_>,
|
|
|
|
from_id: i32,
|
|
|
|
form: &ModRemovePostForm,
|
|
|
|
) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::mod_remove_post::dsl::mod_remove_post;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2019-04-15 23:12:06 +00:00
|
|
|
diesel::update(mod_remove_post.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2019-04-15 23:12:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
#[async_trait]
|
2021-08-17 18:04:58 +00:00
|
|
|
impl Crud for ModLockPost {
|
2022-10-27 09:24:07 +00:00
|
|
|
type InsertForm = ModLockPostForm;
|
|
|
|
type UpdateForm = ModLockPostForm;
|
2021-08-17 18:04:58 +00:00
|
|
|
type IdType = i32;
|
2019-04-15 23:12:06 +00:00
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn create(pool: &mut DbPool<'_>, form: &ModLockPostForm) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::mod_lock_post::dsl::mod_lock_post;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2019-09-07 15:35:05 +00:00
|
|
|
insert_into(mod_lock_post)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2019-04-15 23:12:06 +00:00
|
|
|
}
|
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn update(
|
|
|
|
pool: &mut DbPool<'_>,
|
|
|
|
from_id: i32,
|
|
|
|
form: &ModLockPostForm,
|
|
|
|
) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::mod_lock_post::dsl::mod_lock_post;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2019-04-15 23:12:06 +00:00
|
|
|
diesel::update(mod_lock_post.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2019-04-15 23:12:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
#[async_trait]
|
2022-12-12 11:17:10 +00:00
|
|
|
impl Crud for ModFeaturePost {
|
|
|
|
type InsertForm = ModFeaturePostForm;
|
|
|
|
type UpdateForm = ModFeaturePostForm;
|
2021-08-17 18:04:58 +00:00
|
|
|
type IdType = i32;
|
2019-09-09 06:14:13 +00:00
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn create(pool: &mut DbPool<'_>, form: &ModFeaturePostForm) -> Result<Self, Error> {
|
2022-12-12 11:17:10 +00:00
|
|
|
use crate::schema::mod_feature_post::dsl::mod_feature_post;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2022-12-12 11:17:10 +00:00
|
|
|
insert_into(mod_feature_post)
|
2019-09-09 06:14:13 +00:00
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2019-09-09 06:14:13 +00:00
|
|
|
}
|
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn update(
|
|
|
|
pool: &mut DbPool<'_>,
|
|
|
|
from_id: i32,
|
|
|
|
form: &ModFeaturePostForm,
|
|
|
|
) -> Result<Self, Error> {
|
2022-12-12 11:17:10 +00:00
|
|
|
use crate::schema::mod_feature_post::dsl::mod_feature_post;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2022-12-12 11:17:10 +00:00
|
|
|
diesel::update(mod_feature_post.find(from_id))
|
2019-09-09 06:14:13 +00:00
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2019-09-09 06:14:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
#[async_trait]
|
2021-08-17 18:04:58 +00:00
|
|
|
impl Crud for ModRemoveComment {
|
2022-10-27 09:24:07 +00:00
|
|
|
type InsertForm = ModRemoveCommentForm;
|
|
|
|
type UpdateForm = ModRemoveCommentForm;
|
2021-08-17 18:04:58 +00:00
|
|
|
type IdType = i32;
|
2019-04-15 23:12:06 +00:00
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn create(pool: &mut DbPool<'_>, form: &ModRemoveCommentForm) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::mod_remove_comment::dsl::mod_remove_comment;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2019-09-07 15:35:05 +00:00
|
|
|
insert_into(mod_remove_comment)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2019-04-15 23:12:06 +00:00
|
|
|
}
|
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn update(
|
|
|
|
pool: &mut DbPool<'_>,
|
|
|
|
from_id: i32,
|
|
|
|
form: &ModRemoveCommentForm,
|
|
|
|
) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::mod_remove_comment::dsl::mod_remove_comment;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2019-04-15 23:12:06 +00:00
|
|
|
diesel::update(mod_remove_comment.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2019-04-15 23:12:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
#[async_trait]
|
2021-08-17 18:04:58 +00:00
|
|
|
impl Crud for ModRemoveCommunity {
|
2022-10-27 09:24:07 +00:00
|
|
|
type InsertForm = ModRemoveCommunityForm;
|
|
|
|
type UpdateForm = ModRemoveCommunityForm;
|
2021-08-17 18:04:58 +00:00
|
|
|
type IdType = i32;
|
2019-04-15 23:12:06 +00:00
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn create(pool: &mut DbPool<'_>, form: &ModRemoveCommunityForm) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::mod_remove_community::dsl::mod_remove_community;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2019-09-07 15:35:05 +00:00
|
|
|
insert_into(mod_remove_community)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2019-04-15 23:12:06 +00:00
|
|
|
}
|
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
async fn update(
|
2023-07-11 13:09:59 +00:00
|
|
|
pool: &mut DbPool<'_>,
|
2019-09-07 15:35:05 +00:00
|
|
|
from_id: i32,
|
|
|
|
form: &ModRemoveCommunityForm,
|
|
|
|
) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::mod_remove_community::dsl::mod_remove_community;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2019-04-15 23:12:06 +00:00
|
|
|
diesel::update(mod_remove_community.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2019-04-15 23:12:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
#[async_trait]
|
2021-08-17 18:04:58 +00:00
|
|
|
impl Crud for ModBanFromCommunity {
|
2022-10-27 09:24:07 +00:00
|
|
|
type InsertForm = ModBanFromCommunityForm;
|
|
|
|
type UpdateForm = ModBanFromCommunityForm;
|
2021-08-17 18:04:58 +00:00
|
|
|
type IdType = i32;
|
2019-04-15 23:12:06 +00:00
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn create(pool: &mut DbPool<'_>, form: &ModBanFromCommunityForm) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::mod_ban_from_community::dsl::mod_ban_from_community;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2019-09-07 15:35:05 +00:00
|
|
|
insert_into(mod_ban_from_community)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2019-04-15 23:12:06 +00:00
|
|
|
}
|
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
async fn update(
|
2023-07-11 13:09:59 +00:00
|
|
|
pool: &mut DbPool<'_>,
|
2019-09-07 15:35:05 +00:00
|
|
|
from_id: i32,
|
|
|
|
form: &ModBanFromCommunityForm,
|
|
|
|
) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::mod_ban_from_community::dsl::mod_ban_from_community;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2019-04-15 23:12:06 +00:00
|
|
|
diesel::update(mod_ban_from_community.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2019-04-15 23:12:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
#[async_trait]
|
2021-08-17 18:04:58 +00:00
|
|
|
impl Crud for ModBan {
|
2022-10-27 09:24:07 +00:00
|
|
|
type InsertForm = ModBanForm;
|
|
|
|
type UpdateForm = ModBanForm;
|
2021-08-17 18:04:58 +00:00
|
|
|
type IdType = i32;
|
2019-04-15 23:12:06 +00:00
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn create(pool: &mut DbPool<'_>, form: &ModBanForm) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::mod_ban::dsl::mod_ban;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
|
|
|
insert_into(mod_ban)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
2019-04-15 23:12:06 +00:00
|
|
|
}
|
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn update(pool: &mut DbPool<'_>, from_id: i32, form: &ModBanForm) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::mod_ban::dsl::mod_ban;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2019-04-15 23:12:06 +00:00
|
|
|
diesel::update(mod_ban.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2019-04-15 23:12:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
#[async_trait]
|
2022-02-18 02:30:47 +00:00
|
|
|
impl Crud for ModHideCommunity {
|
2022-10-27 09:24:07 +00:00
|
|
|
type InsertForm = ModHideCommunityForm;
|
|
|
|
type UpdateForm = ModHideCommunityForm;
|
2022-02-18 02:30:47 +00:00
|
|
|
type IdType = i32;
|
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn create(pool: &mut DbPool<'_>, form: &ModHideCommunityForm) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::mod_hide_community::dsl::mod_hide_community;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2022-02-18 02:30:47 +00:00
|
|
|
insert_into(mod_hide_community)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2022-02-18 02:30:47 +00:00
|
|
|
}
|
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn update(
|
|
|
|
pool: &mut DbPool<'_>,
|
|
|
|
from_id: i32,
|
|
|
|
form: &ModHideCommunityForm,
|
|
|
|
) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::mod_hide_community::dsl::mod_hide_community;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2022-02-18 02:30:47 +00:00
|
|
|
diesel::update(mod_hide_community.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2022-02-18 02:30:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
#[async_trait]
|
2021-08-17 18:04:58 +00:00
|
|
|
impl Crud for ModAddCommunity {
|
2022-10-27 09:24:07 +00:00
|
|
|
type InsertForm = ModAddCommunityForm;
|
|
|
|
type UpdateForm = ModAddCommunityForm;
|
2021-08-17 18:04:58 +00:00
|
|
|
type IdType = i32;
|
2019-04-15 23:12:06 +00:00
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn create(pool: &mut DbPool<'_>, form: &ModAddCommunityForm) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::mod_add_community::dsl::mod_add_community;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2019-09-07 15:35:05 +00:00
|
|
|
insert_into(mod_add_community)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2019-04-15 23:12:06 +00:00
|
|
|
}
|
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn update(
|
|
|
|
pool: &mut DbPool<'_>,
|
|
|
|
from_id: i32,
|
|
|
|
form: &ModAddCommunityForm,
|
|
|
|
) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::mod_add_community::dsl::mod_add_community;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2019-04-15 23:12:06 +00:00
|
|
|
diesel::update(mod_add_community.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2019-04-15 23:12:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
#[async_trait]
|
2021-08-17 21:52:28 +00:00
|
|
|
impl Crud for ModTransferCommunity {
|
2022-10-27 09:24:07 +00:00
|
|
|
type InsertForm = ModTransferCommunityForm;
|
|
|
|
type UpdateForm = ModTransferCommunityForm;
|
2021-08-17 21:52:28 +00:00
|
|
|
type IdType = i32;
|
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn create(pool: &mut DbPool<'_>, form: &ModTransferCommunityForm) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::mod_transfer_community::dsl::mod_transfer_community;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2021-08-17 21:52:28 +00:00
|
|
|
insert_into(mod_transfer_community)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2021-08-17 21:52:28 +00:00
|
|
|
}
|
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
async fn update(
|
2023-07-11 13:09:59 +00:00
|
|
|
pool: &mut DbPool<'_>,
|
2021-08-17 21:52:28 +00:00
|
|
|
from_id: i32,
|
|
|
|
form: &ModTransferCommunityForm,
|
|
|
|
) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::mod_transfer_community::dsl::mod_transfer_community;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2021-08-17 21:52:28 +00:00
|
|
|
diesel::update(mod_transfer_community.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2021-08-17 21:52:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
#[async_trait]
|
2021-08-17 18:04:58 +00:00
|
|
|
impl Crud for ModAdd {
|
2022-10-27 09:24:07 +00:00
|
|
|
type InsertForm = ModAddForm;
|
|
|
|
type UpdateForm = ModAddForm;
|
2021-08-17 18:04:58 +00:00
|
|
|
type IdType = i32;
|
2019-04-15 23:12:06 +00:00
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn create(pool: &mut DbPool<'_>, form: &ModAddForm) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::mod_add::dsl::mod_add;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
|
|
|
insert_into(mod_add)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
2019-04-15 23:12:06 +00:00
|
|
|
}
|
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn update(pool: &mut DbPool<'_>, from_id: i32, form: &ModAddForm) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::mod_add::dsl::mod_add;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2019-04-15 23:12:06 +00:00
|
|
|
diesel::update(mod_add.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2019-04-15 23:12:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
#[async_trait]
|
2022-06-13 19:15:04 +00:00
|
|
|
impl Crud for AdminPurgePerson {
|
2022-10-27 09:24:07 +00:00
|
|
|
type InsertForm = AdminPurgePersonForm;
|
|
|
|
type UpdateForm = AdminPurgePersonForm;
|
2022-06-13 19:15:04 +00:00
|
|
|
type IdType = i32;
|
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::admin_purge_person::dsl::admin_purge_person;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2022-06-13 19:15:04 +00:00
|
|
|
insert_into(admin_purge_person)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2022-06-13 19:15:04 +00:00
|
|
|
}
|
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn update(
|
|
|
|
pool: &mut DbPool<'_>,
|
|
|
|
from_id: i32,
|
|
|
|
form: &Self::InsertForm,
|
|
|
|
) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::admin_purge_person::dsl::admin_purge_person;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2022-06-13 19:15:04 +00:00
|
|
|
diesel::update(admin_purge_person.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2022-06-13 19:15:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
#[async_trait]
|
2022-06-13 19:15:04 +00:00
|
|
|
impl Crud for AdminPurgeCommunity {
|
2022-10-27 09:24:07 +00:00
|
|
|
type InsertForm = AdminPurgeCommunityForm;
|
|
|
|
type UpdateForm = AdminPurgeCommunityForm;
|
2022-06-13 19:15:04 +00:00
|
|
|
type IdType = i32;
|
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::admin_purge_community::dsl::admin_purge_community;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2022-06-13 19:15:04 +00:00
|
|
|
insert_into(admin_purge_community)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2022-06-13 19:15:04 +00:00
|
|
|
}
|
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn update(
|
|
|
|
pool: &mut DbPool<'_>,
|
|
|
|
from_id: i32,
|
|
|
|
form: &Self::InsertForm,
|
|
|
|
) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::admin_purge_community::dsl::admin_purge_community;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2022-06-13 19:15:04 +00:00
|
|
|
diesel::update(admin_purge_community.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2022-06-13 19:15:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
#[async_trait]
|
2022-06-13 19:15:04 +00:00
|
|
|
impl Crud for AdminPurgePost {
|
2022-10-27 09:24:07 +00:00
|
|
|
type InsertForm = AdminPurgePostForm;
|
|
|
|
type UpdateForm = AdminPurgePostForm;
|
2022-06-13 19:15:04 +00:00
|
|
|
type IdType = i32;
|
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::admin_purge_post::dsl::admin_purge_post;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2022-06-13 19:15:04 +00:00
|
|
|
insert_into(admin_purge_post)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2022-06-13 19:15:04 +00:00
|
|
|
}
|
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn update(
|
|
|
|
pool: &mut DbPool<'_>,
|
|
|
|
from_id: i32,
|
|
|
|
form: &Self::InsertForm,
|
|
|
|
) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::admin_purge_post::dsl::admin_purge_post;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2022-06-13 19:15:04 +00:00
|
|
|
diesel::update(admin_purge_post.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2022-06-13 19:15:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
#[async_trait]
|
2022-06-13 19:15:04 +00:00
|
|
|
impl Crud for AdminPurgeComment {
|
2022-10-27 09:24:07 +00:00
|
|
|
type InsertForm = AdminPurgeCommentForm;
|
|
|
|
type UpdateForm = AdminPurgeCommentForm;
|
2022-06-13 19:15:04 +00:00
|
|
|
type IdType = i32;
|
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::admin_purge_comment::dsl::admin_purge_comment;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2022-06-13 19:15:04 +00:00
|
|
|
insert_into(admin_purge_comment)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2022-06-13 19:15:04 +00:00
|
|
|
}
|
|
|
|
|
2023-07-11 13:09:59 +00:00
|
|
|
async fn update(
|
|
|
|
pool: &mut DbPool<'_>,
|
|
|
|
from_id: i32,
|
|
|
|
form: &Self::InsertForm,
|
|
|
|
) -> Result<Self, Error> {
|
2022-11-19 04:33:54 +00:00
|
|
|
use crate::schema::admin_purge_comment::dsl::admin_purge_comment;
|
2022-11-09 10:05:00 +00:00
|
|
|
let conn = &mut get_conn(pool).await?;
|
2022-06-13 19:15:04 +00:00
|
|
|
diesel::update(admin_purge_comment.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(conn)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
2022-06-13 19:15:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-15 23:12:06 +00:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
2023-07-17 15:04:14 +00:00
|
|
|
#![allow(clippy::unwrap_used)]
|
|
|
|
#![allow(clippy::indexing_slicing)]
|
|
|
|
|
2021-10-16 13:33:38 +00:00
|
|
|
use crate::{
|
2022-11-19 04:33:54 +00:00
|
|
|
source::{
|
|
|
|
comment::{Comment, CommentInsertForm},
|
|
|
|
community::{Community, CommunityInsertForm},
|
|
|
|
instance::Instance,
|
|
|
|
moderator::{
|
|
|
|
ModAdd,
|
|
|
|
ModAddCommunity,
|
|
|
|
ModAddCommunityForm,
|
|
|
|
ModAddForm,
|
|
|
|
ModBan,
|
|
|
|
ModBanForm,
|
|
|
|
ModBanFromCommunity,
|
|
|
|
ModBanFromCommunityForm,
|
2022-12-12 11:17:10 +00:00
|
|
|
ModFeaturePost,
|
|
|
|
ModFeaturePostForm,
|
2022-11-19 04:33:54 +00:00
|
|
|
ModLockPost,
|
|
|
|
ModLockPostForm,
|
|
|
|
ModRemoveComment,
|
|
|
|
ModRemoveCommentForm,
|
|
|
|
ModRemoveCommunity,
|
|
|
|
ModRemoveCommunityForm,
|
|
|
|
ModRemovePost,
|
|
|
|
ModRemovePostForm,
|
|
|
|
},
|
|
|
|
person::{Person, PersonInsertForm},
|
|
|
|
post::{Post, PostInsertForm},
|
|
|
|
},
|
2021-10-16 13:33:38 +00:00
|
|
|
traits::Crud,
|
2022-11-09 10:05:00 +00:00
|
|
|
utils::build_db_pool_for_tests,
|
2021-10-16 13:33:38 +00:00
|
|
|
};
|
2021-02-25 19:43:39 +00:00
|
|
|
use serial_test::serial;
|
2022-11-19 04:33:54 +00:00
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
#[tokio::test]
|
2021-02-25 19:43:39 +00:00
|
|
|
#[serial]
|
2022-11-09 10:05:00 +00:00
|
|
|
async fn test_crud() {
|
|
|
|
let pool = &build_db_pool_for_tests().await;
|
2023-07-11 13:09:59 +00:00
|
|
|
let pool = &mut pool.into();
|
2019-04-15 23:12:06 +00:00
|
|
|
|
2023-03-01 02:36:57 +00:00
|
|
|
let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string())
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2022-10-27 09:24:07 +00:00
|
|
|
|
|
|
|
let new_mod = PersonInsertForm::builder()
|
|
|
|
.name("the mod".into())
|
|
|
|
.public_key("pubkey".to_string())
|
|
|
|
.instance_id(inserted_instance.id)
|
|
|
|
.build();
|
2019-04-15 23:12:06 +00:00
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
let inserted_mod = Person::create(pool, &new_mod).await.unwrap();
|
2019-04-15 23:12:06 +00:00
|
|
|
|
2022-10-27 09:24:07 +00:00
|
|
|
let new_person = PersonInsertForm::builder()
|
|
|
|
.name("jim2".into())
|
|
|
|
.public_key("pubkey".to_string())
|
|
|
|
.instance_id(inserted_instance.id)
|
|
|
|
.build();
|
2019-04-15 23:12:06 +00:00
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
let inserted_person = Person::create(pool, &new_person).await.unwrap();
|
2019-04-15 23:12:06 +00:00
|
|
|
|
2022-10-27 09:24:07 +00:00
|
|
|
let new_community = CommunityInsertForm::builder()
|
|
|
|
.name("mod_community".to_string())
|
|
|
|
.title("nada".to_owned())
|
|
|
|
.public_key("pubkey".to_string())
|
|
|
|
.instance_id(inserted_instance.id)
|
|
|
|
.build();
|
2019-04-15 23:12:06 +00:00
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
let inserted_community = Community::create(pool, &new_community).await.unwrap();
|
2019-09-07 15:35:05 +00:00
|
|
|
|
2022-10-27 09:24:07 +00:00
|
|
|
let new_post = PostInsertForm::builder()
|
|
|
|
.name("A test post thweep".into())
|
|
|
|
.creator_id(inserted_person.id)
|
|
|
|
.community_id(inserted_community.id)
|
|
|
|
.build();
|
2019-04-15 23:12:06 +00:00
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
let inserted_post = Post::create(pool, &new_post).await.unwrap();
|
2019-04-15 23:12:06 +00:00
|
|
|
|
2022-10-27 09:24:07 +00:00
|
|
|
let comment_form = CommentInsertForm::builder()
|
|
|
|
.content("A test comment".into())
|
|
|
|
.creator_id(inserted_person.id)
|
|
|
|
.post_id(inserted_post.id)
|
|
|
|
.build();
|
2019-04-15 23:12:06 +00:00
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
let inserted_comment = Comment::create(pool, &comment_form, None).await.unwrap();
|
2019-04-15 23:12:06 +00:00
|
|
|
|
|
|
|
// Now the actual tests
|
|
|
|
|
|
|
|
// remove post
|
|
|
|
let mod_remove_post_form = ModRemovePostForm {
|
2021-02-26 13:49:58 +00:00
|
|
|
mod_person_id: inserted_mod.id,
|
2019-04-15 23:12:06 +00:00
|
|
|
post_id: inserted_post.id,
|
|
|
|
reason: None,
|
|
|
|
removed: None,
|
|
|
|
};
|
2022-11-09 10:05:00 +00:00
|
|
|
let inserted_mod_remove_post = ModRemovePost::create(pool, &mod_remove_post_form)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
let read_mod_remove_post = ModRemovePost::read(pool, inserted_mod_remove_post.id)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2019-09-09 06:14:13 +00:00
|
|
|
let expected_mod_remove_post = ModRemovePost {
|
2019-04-15 23:12:06 +00:00
|
|
|
id: inserted_mod_remove_post.id,
|
|
|
|
post_id: inserted_post.id,
|
2021-02-26 13:49:58 +00:00
|
|
|
mod_person_id: inserted_mod.id,
|
2019-04-15 23:12:06 +00:00
|
|
|
reason: None,
|
2023-04-17 19:19:51 +00:00
|
|
|
removed: true,
|
2019-04-15 23:12:06 +00:00
|
|
|
when_: inserted_mod_remove_post.when_,
|
|
|
|
};
|
|
|
|
|
|
|
|
// lock post
|
|
|
|
|
|
|
|
let mod_lock_post_form = ModLockPostForm {
|
2021-02-26 13:49:58 +00:00
|
|
|
mod_person_id: inserted_mod.id,
|
2019-04-15 23:12:06 +00:00
|
|
|
post_id: inserted_post.id,
|
|
|
|
locked: None,
|
|
|
|
};
|
2022-11-09 10:05:00 +00:00
|
|
|
let inserted_mod_lock_post = ModLockPost::create(pool, &mod_lock_post_form)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
let read_mod_lock_post = ModLockPost::read(pool, inserted_mod_lock_post.id)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2019-09-09 06:14:13 +00:00
|
|
|
let expected_mod_lock_post = ModLockPost {
|
2019-04-15 23:12:06 +00:00
|
|
|
id: inserted_mod_lock_post.id,
|
|
|
|
post_id: inserted_post.id,
|
2021-02-26 13:49:58 +00:00
|
|
|
mod_person_id: inserted_mod.id,
|
2023-04-17 19:19:51 +00:00
|
|
|
locked: true,
|
2019-04-15 23:12:06 +00:00
|
|
|
when_: inserted_mod_lock_post.when_,
|
|
|
|
};
|
|
|
|
|
2022-12-12 11:17:10 +00:00
|
|
|
// feature post
|
2019-09-09 06:14:13 +00:00
|
|
|
|
2022-12-12 11:17:10 +00:00
|
|
|
let mod_feature_post_form = ModFeaturePostForm {
|
2021-02-26 13:49:58 +00:00
|
|
|
mod_person_id: inserted_mod.id,
|
2019-09-09 06:14:13 +00:00
|
|
|
post_id: inserted_post.id,
|
2022-12-12 11:17:10 +00:00
|
|
|
featured: false,
|
|
|
|
is_featured_community: true,
|
2019-09-09 06:14:13 +00:00
|
|
|
};
|
2022-12-12 11:17:10 +00:00
|
|
|
let inserted_mod_feature_post = ModFeaturePost::create(pool, &mod_feature_post_form)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
|
|
|
.unwrap();
|
2022-12-12 11:17:10 +00:00
|
|
|
let read_mod_feature_post = ModFeaturePost::read(pool, inserted_mod_feature_post.id)
|
2022-11-09 10:05:00 +00:00
|
|
|
.await
|
|
|
|
.unwrap();
|
2022-12-12 11:17:10 +00:00
|
|
|
let expected_mod_feature_post = ModFeaturePost {
|
|
|
|
id: inserted_mod_feature_post.id,
|
2019-09-09 06:14:13 +00:00
|
|
|
post_id: inserted_post.id,
|
2021-02-26 13:49:58 +00:00
|
|
|
mod_person_id: inserted_mod.id,
|
2022-12-12 11:17:10 +00:00
|
|
|
featured: false,
|
|
|
|
is_featured_community: true,
|
|
|
|
when_: inserted_mod_feature_post.when_,
|
2019-09-09 06:14:13 +00:00
|
|
|
};
|
|
|
|
|
2019-04-15 23:12:06 +00:00
|
|
|
// comment
|
|
|
|
|
|
|
|
let mod_remove_comment_form = ModRemoveCommentForm {
|
2021-02-26 13:49:58 +00:00
|
|
|
mod_person_id: inserted_mod.id,
|
2019-04-15 23:12:06 +00:00
|
|
|
comment_id: inserted_comment.id,
|
|
|
|
reason: None,
|
|
|
|
removed: None,
|
|
|
|
};
|
2022-11-09 10:05:00 +00:00
|
|
|
let inserted_mod_remove_comment = ModRemoveComment::create(pool, &mod_remove_comment_form)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
let read_mod_remove_comment = ModRemoveComment::read(pool, inserted_mod_remove_comment.id)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2019-09-09 06:14:13 +00:00
|
|
|
let expected_mod_remove_comment = ModRemoveComment {
|
2019-04-15 23:12:06 +00:00
|
|
|
id: inserted_mod_remove_comment.id,
|
|
|
|
comment_id: inserted_comment.id,
|
2021-02-26 13:49:58 +00:00
|
|
|
mod_person_id: inserted_mod.id,
|
2019-04-15 23:12:06 +00:00
|
|
|
reason: None,
|
2023-04-17 19:19:51 +00:00
|
|
|
removed: true,
|
2019-04-15 23:12:06 +00:00
|
|
|
when_: inserted_mod_remove_comment.when_,
|
|
|
|
};
|
|
|
|
|
|
|
|
// community
|
|
|
|
|
|
|
|
let mod_remove_community_form = ModRemoveCommunityForm {
|
2021-02-26 13:49:58 +00:00
|
|
|
mod_person_id: inserted_mod.id,
|
2019-04-15 23:12:06 +00:00
|
|
|
community_id: inserted_community.id,
|
|
|
|
reason: None,
|
|
|
|
removed: None,
|
|
|
|
};
|
2019-09-07 15:35:05 +00:00
|
|
|
let inserted_mod_remove_community =
|
2022-11-09 10:05:00 +00:00
|
|
|
ModRemoveCommunity::create(pool, &mod_remove_community_form)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2019-09-09 06:14:13 +00:00
|
|
|
let read_mod_remove_community =
|
2022-11-09 10:05:00 +00:00
|
|
|
ModRemoveCommunity::read(pool, inserted_mod_remove_community.id)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2019-09-09 06:14:13 +00:00
|
|
|
let expected_mod_remove_community = ModRemoveCommunity {
|
2019-04-15 23:12:06 +00:00
|
|
|
id: inserted_mod_remove_community.id,
|
|
|
|
community_id: inserted_community.id,
|
2021-02-26 13:49:58 +00:00
|
|
|
mod_person_id: inserted_mod.id,
|
2019-04-15 23:12:06 +00:00
|
|
|
reason: None,
|
2023-04-17 19:19:51 +00:00
|
|
|
removed: true,
|
2019-04-15 23:12:06 +00:00
|
|
|
when_: inserted_mod_remove_community.when_,
|
|
|
|
};
|
|
|
|
|
|
|
|
// ban from community
|
|
|
|
|
|
|
|
let mod_ban_from_community_form = ModBanFromCommunityForm {
|
2021-02-26 13:49:58 +00:00
|
|
|
mod_person_id: inserted_mod.id,
|
|
|
|
other_person_id: inserted_person.id,
|
2019-04-15 23:12:06 +00:00
|
|
|
community_id: inserted_community.id,
|
|
|
|
reason: None,
|
|
|
|
banned: None,
|
|
|
|
expires: None,
|
|
|
|
};
|
2019-09-07 15:35:05 +00:00
|
|
|
let inserted_mod_ban_from_community =
|
2022-11-09 10:05:00 +00:00
|
|
|
ModBanFromCommunity::create(pool, &mod_ban_from_community_form)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2019-09-09 06:14:13 +00:00
|
|
|
let read_mod_ban_from_community =
|
2022-11-09 10:05:00 +00:00
|
|
|
ModBanFromCommunity::read(pool, inserted_mod_ban_from_community.id)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2019-09-09 06:14:13 +00:00
|
|
|
let expected_mod_ban_from_community = ModBanFromCommunity {
|
2019-04-15 23:12:06 +00:00
|
|
|
id: inserted_mod_ban_from_community.id,
|
|
|
|
community_id: inserted_community.id,
|
2021-02-26 13:49:58 +00:00
|
|
|
mod_person_id: inserted_mod.id,
|
|
|
|
other_person_id: inserted_person.id,
|
2019-04-15 23:12:06 +00:00
|
|
|
reason: None,
|
2023-04-17 19:19:51 +00:00
|
|
|
banned: true,
|
2019-04-15 23:12:06 +00:00
|
|
|
expires: None,
|
|
|
|
when_: inserted_mod_ban_from_community.when_,
|
|
|
|
};
|
|
|
|
|
|
|
|
// ban
|
|
|
|
|
|
|
|
let mod_ban_form = ModBanForm {
|
2021-02-26 13:49:58 +00:00
|
|
|
mod_person_id: inserted_mod.id,
|
|
|
|
other_person_id: inserted_person.id,
|
2019-04-15 23:12:06 +00:00
|
|
|
reason: None,
|
|
|
|
banned: None,
|
|
|
|
expires: None,
|
|
|
|
};
|
2022-11-09 10:05:00 +00:00
|
|
|
let inserted_mod_ban = ModBan::create(pool, &mod_ban_form).await.unwrap();
|
|
|
|
let read_mod_ban = ModBan::read(pool, inserted_mod_ban.id).await.unwrap();
|
2019-09-09 06:14:13 +00:00
|
|
|
let expected_mod_ban = ModBan {
|
2019-04-15 23:12:06 +00:00
|
|
|
id: inserted_mod_ban.id,
|
2021-02-26 13:49:58 +00:00
|
|
|
mod_person_id: inserted_mod.id,
|
|
|
|
other_person_id: inserted_person.id,
|
2019-04-15 23:12:06 +00:00
|
|
|
reason: None,
|
2023-04-17 19:19:51 +00:00
|
|
|
banned: true,
|
2019-04-15 23:12:06 +00:00
|
|
|
expires: None,
|
|
|
|
when_: inserted_mod_ban.when_,
|
|
|
|
};
|
|
|
|
|
|
|
|
// mod add community
|
|
|
|
|
|
|
|
let mod_add_community_form = ModAddCommunityForm {
|
2021-02-26 13:49:58 +00:00
|
|
|
mod_person_id: inserted_mod.id,
|
|
|
|
other_person_id: inserted_person.id,
|
2019-04-15 23:12:06 +00:00
|
|
|
community_id: inserted_community.id,
|
|
|
|
removed: None,
|
|
|
|
};
|
2022-11-09 10:05:00 +00:00
|
|
|
let inserted_mod_add_community = ModAddCommunity::create(pool, &mod_add_community_form)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
let read_mod_add_community = ModAddCommunity::read(pool, inserted_mod_add_community.id)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2019-09-09 06:14:13 +00:00
|
|
|
let expected_mod_add_community = ModAddCommunity {
|
2019-04-15 23:12:06 +00:00
|
|
|
id: inserted_mod_add_community.id,
|
|
|
|
community_id: inserted_community.id,
|
2021-02-26 13:49:58 +00:00
|
|
|
mod_person_id: inserted_mod.id,
|
|
|
|
other_person_id: inserted_person.id,
|
2023-04-17 19:19:51 +00:00
|
|
|
removed: false,
|
2019-04-15 23:12:06 +00:00
|
|
|
when_: inserted_mod_add_community.when_,
|
|
|
|
};
|
|
|
|
|
|
|
|
// mod add
|
|
|
|
|
|
|
|
let mod_add_form = ModAddForm {
|
2021-02-26 13:49:58 +00:00
|
|
|
mod_person_id: inserted_mod.id,
|
|
|
|
other_person_id: inserted_person.id,
|
2019-04-15 23:12:06 +00:00
|
|
|
removed: None,
|
|
|
|
};
|
2022-11-09 10:05:00 +00:00
|
|
|
let inserted_mod_add = ModAdd::create(pool, &mod_add_form).await.unwrap();
|
|
|
|
let read_mod_add = ModAdd::read(pool, inserted_mod_add.id).await.unwrap();
|
2019-09-09 06:14:13 +00:00
|
|
|
let expected_mod_add = ModAdd {
|
2019-04-15 23:12:06 +00:00
|
|
|
id: inserted_mod_add.id,
|
2021-02-26 13:49:58 +00:00
|
|
|
mod_person_id: inserted_mod.id,
|
|
|
|
other_person_id: inserted_person.id,
|
2023-04-17 19:19:51 +00:00
|
|
|
removed: false,
|
2019-04-15 23:12:06 +00:00
|
|
|
when_: inserted_mod_add.when_,
|
|
|
|
};
|
|
|
|
|
2022-11-09 10:05:00 +00:00
|
|
|
Comment::delete(pool, inserted_comment.id).await.unwrap();
|
|
|
|
Post::delete(pool, inserted_post.id).await.unwrap();
|
|
|
|
Community::delete(pool, inserted_community.id)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
Person::delete(pool, inserted_person.id).await.unwrap();
|
|
|
|
Person::delete(pool, inserted_mod.id).await.unwrap();
|
|
|
|
Instance::delete(pool, inserted_instance.id).await.unwrap();
|
2019-04-15 23:12:06 +00:00
|
|
|
|
2019-09-09 06:14:13 +00:00
|
|
|
assert_eq!(expected_mod_remove_post, read_mod_remove_post);
|
|
|
|
assert_eq!(expected_mod_lock_post, read_mod_lock_post);
|
2022-12-12 11:17:10 +00:00
|
|
|
assert_eq!(expected_mod_feature_post, read_mod_feature_post);
|
2019-09-09 06:14:13 +00:00
|
|
|
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);
|
2019-04-15 23:12:06 +00:00
|
|
|
}
|
|
|
|
}
|