|
|
@ -32,41 +32,41 @@ use crate::{
|
|
|
|
ModTransferCommunityForm,
|
|
|
|
ModTransferCommunityForm,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
traits::Crud,
|
|
|
|
traits::Crud,
|
|
|
|
utils::DbConn,
|
|
|
|
utils::GetConn,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
use diesel::{dsl::insert_into, result::Error, QueryDsl};
|
|
|
|
use diesel::{dsl::insert_into, result::Error, QueryDsl};
|
|
|
|
use diesel_async::RunQueryDsl;
|
|
|
|
use lemmy_db_schema::utils::RunQueryDsl;
|
|
|
|
|
|
|
|
|
|
|
|
#[async_trait]
|
|
|
|
#[async_trait]
|
|
|
|
impl Crud for ModRemovePost {
|
|
|
|
impl Crud for ModRemovePost {
|
|
|
|
type InsertForm = ModRemovePostForm;
|
|
|
|
type InsertForm = ModRemovePostForm;
|
|
|
|
type UpdateForm = ModRemovePostForm;
|
|
|
|
type UpdateForm = ModRemovePostForm;
|
|
|
|
type IdType = i32;
|
|
|
|
type IdType = i32;
|
|
|
|
async fn read(mut conn: impl DbConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
async fn read(mut conn: impl GetConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_remove_post::dsl::mod_remove_post;
|
|
|
|
use crate::schema::mod_remove_post::dsl::mod_remove_post;
|
|
|
|
mod_remove_post
|
|
|
|
mod_remove_post
|
|
|
|
.find(from_id)
|
|
|
|
.find(from_id)
|
|
|
|
.first::<Self>(&mut *conn)
|
|
|
|
.first::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn create(mut conn: impl DbConn, form: &ModRemovePostForm) -> Result<Self, Error> {
|
|
|
|
async fn create(mut conn: impl GetConn, form: &ModRemovePostForm) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_remove_post::dsl::mod_remove_post;
|
|
|
|
use crate::schema::mod_remove_post::dsl::mod_remove_post;
|
|
|
|
insert_into(mod_remove_post)
|
|
|
|
insert_into(mod_remove_post)
|
|
|
|
.values(form)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn update(
|
|
|
|
async fn update(
|
|
|
|
mut conn: impl DbConn,
|
|
|
|
mut conn: impl GetConn,
|
|
|
|
from_id: i32,
|
|
|
|
from_id: i32,
|
|
|
|
form: &ModRemovePostForm,
|
|
|
|
form: &ModRemovePostForm,
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_remove_post::dsl::mod_remove_post;
|
|
|
|
use crate::schema::mod_remove_post::dsl::mod_remove_post;
|
|
|
|
diesel::update(mod_remove_post.find(from_id))
|
|
|
|
diesel::update(mod_remove_post.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -76,28 +76,28 @@ impl Crud for ModLockPost {
|
|
|
|
type InsertForm = ModLockPostForm;
|
|
|
|
type InsertForm = ModLockPostForm;
|
|
|
|
type UpdateForm = ModLockPostForm;
|
|
|
|
type UpdateForm = ModLockPostForm;
|
|
|
|
type IdType = i32;
|
|
|
|
type IdType = i32;
|
|
|
|
async fn read(mut conn: impl DbConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
async fn read(mut conn: impl GetConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_lock_post::dsl::mod_lock_post;
|
|
|
|
use crate::schema::mod_lock_post::dsl::mod_lock_post;
|
|
|
|
mod_lock_post.find(from_id).first::<Self>(&mut *conn).await
|
|
|
|
mod_lock_post.find(from_id).first::<Self>(conn).await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn create(mut conn: impl DbConn, form: &ModLockPostForm) -> Result<Self, Error> {
|
|
|
|
async fn create(mut conn: impl GetConn, form: &ModLockPostForm) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_lock_post::dsl::mod_lock_post;
|
|
|
|
use crate::schema::mod_lock_post::dsl::mod_lock_post;
|
|
|
|
insert_into(mod_lock_post)
|
|
|
|
insert_into(mod_lock_post)
|
|
|
|
.values(form)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn update(
|
|
|
|
async fn update(
|
|
|
|
mut conn: impl DbConn,
|
|
|
|
mut conn: impl GetConn,
|
|
|
|
from_id: i32,
|
|
|
|
from_id: i32,
|
|
|
|
form: &ModLockPostForm,
|
|
|
|
form: &ModLockPostForm,
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_lock_post::dsl::mod_lock_post;
|
|
|
|
use crate::schema::mod_lock_post::dsl::mod_lock_post;
|
|
|
|
diesel::update(mod_lock_post.find(from_id))
|
|
|
|
diesel::update(mod_lock_post.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -107,31 +107,31 @@ impl Crud for ModFeaturePost {
|
|
|
|
type InsertForm = ModFeaturePostForm;
|
|
|
|
type InsertForm = ModFeaturePostForm;
|
|
|
|
type UpdateForm = ModFeaturePostForm;
|
|
|
|
type UpdateForm = ModFeaturePostForm;
|
|
|
|
type IdType = i32;
|
|
|
|
type IdType = i32;
|
|
|
|
async fn read(mut conn: impl DbConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
async fn read(mut conn: impl GetConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_feature_post::dsl::mod_feature_post;
|
|
|
|
use crate::schema::mod_feature_post::dsl::mod_feature_post;
|
|
|
|
mod_feature_post
|
|
|
|
mod_feature_post
|
|
|
|
.find(from_id)
|
|
|
|
.find(from_id)
|
|
|
|
.first::<Self>(&mut *conn)
|
|
|
|
.first::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn create(mut conn: impl DbConn, form: &ModFeaturePostForm) -> Result<Self, Error> {
|
|
|
|
async fn create(mut conn: impl GetConn, form: &ModFeaturePostForm) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_feature_post::dsl::mod_feature_post;
|
|
|
|
use crate::schema::mod_feature_post::dsl::mod_feature_post;
|
|
|
|
insert_into(mod_feature_post)
|
|
|
|
insert_into(mod_feature_post)
|
|
|
|
.values(form)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn update(
|
|
|
|
async fn update(
|
|
|
|
mut conn: impl DbConn,
|
|
|
|
mut conn: impl GetConn,
|
|
|
|
from_id: i32,
|
|
|
|
from_id: i32,
|
|
|
|
form: &ModFeaturePostForm,
|
|
|
|
form: &ModFeaturePostForm,
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_feature_post::dsl::mod_feature_post;
|
|
|
|
use crate::schema::mod_feature_post::dsl::mod_feature_post;
|
|
|
|
diesel::update(mod_feature_post.find(from_id))
|
|
|
|
diesel::update(mod_feature_post.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -141,31 +141,31 @@ impl Crud for ModRemoveComment {
|
|
|
|
type InsertForm = ModRemoveCommentForm;
|
|
|
|
type InsertForm = ModRemoveCommentForm;
|
|
|
|
type UpdateForm = ModRemoveCommentForm;
|
|
|
|
type UpdateForm = ModRemoveCommentForm;
|
|
|
|
type IdType = i32;
|
|
|
|
type IdType = i32;
|
|
|
|
async fn read(mut conn: impl DbConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
async fn read(mut conn: impl GetConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_remove_comment::dsl::mod_remove_comment;
|
|
|
|
use crate::schema::mod_remove_comment::dsl::mod_remove_comment;
|
|
|
|
mod_remove_comment
|
|
|
|
mod_remove_comment
|
|
|
|
.find(from_id)
|
|
|
|
.find(from_id)
|
|
|
|
.first::<Self>(&mut *conn)
|
|
|
|
.first::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn create(mut conn: impl DbConn, form: &ModRemoveCommentForm) -> Result<Self, Error> {
|
|
|
|
async fn create(mut conn: impl GetConn, form: &ModRemoveCommentForm) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_remove_comment::dsl::mod_remove_comment;
|
|
|
|
use crate::schema::mod_remove_comment::dsl::mod_remove_comment;
|
|
|
|
insert_into(mod_remove_comment)
|
|
|
|
insert_into(mod_remove_comment)
|
|
|
|
.values(form)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn update(
|
|
|
|
async fn update(
|
|
|
|
mut conn: impl DbConn,
|
|
|
|
mut conn: impl GetConn,
|
|
|
|
from_id: i32,
|
|
|
|
from_id: i32,
|
|
|
|
form: &ModRemoveCommentForm,
|
|
|
|
form: &ModRemoveCommentForm,
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_remove_comment::dsl::mod_remove_comment;
|
|
|
|
use crate::schema::mod_remove_comment::dsl::mod_remove_comment;
|
|
|
|
diesel::update(mod_remove_comment.find(from_id))
|
|
|
|
diesel::update(mod_remove_comment.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -175,31 +175,31 @@ impl Crud for ModRemoveCommunity {
|
|
|
|
type InsertForm = ModRemoveCommunityForm;
|
|
|
|
type InsertForm = ModRemoveCommunityForm;
|
|
|
|
type UpdateForm = ModRemoveCommunityForm;
|
|
|
|
type UpdateForm = ModRemoveCommunityForm;
|
|
|
|
type IdType = i32;
|
|
|
|
type IdType = i32;
|
|
|
|
async fn read(mut conn: impl DbConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
async fn read(mut conn: impl GetConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_remove_community::dsl::mod_remove_community;
|
|
|
|
use crate::schema::mod_remove_community::dsl::mod_remove_community;
|
|
|
|
mod_remove_community
|
|
|
|
mod_remove_community
|
|
|
|
.find(from_id)
|
|
|
|
.find(from_id)
|
|
|
|
.first::<Self>(&mut *conn)
|
|
|
|
.first::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn create(mut conn: impl DbConn, form: &ModRemoveCommunityForm) -> Result<Self, Error> {
|
|
|
|
async fn create(mut conn: impl GetConn, form: &ModRemoveCommunityForm) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_remove_community::dsl::mod_remove_community;
|
|
|
|
use crate::schema::mod_remove_community::dsl::mod_remove_community;
|
|
|
|
insert_into(mod_remove_community)
|
|
|
|
insert_into(mod_remove_community)
|
|
|
|
.values(form)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn update(
|
|
|
|
async fn update(
|
|
|
|
mut conn: impl DbConn,
|
|
|
|
mut conn: impl GetConn,
|
|
|
|
from_id: i32,
|
|
|
|
from_id: i32,
|
|
|
|
form: &ModRemoveCommunityForm,
|
|
|
|
form: &ModRemoveCommunityForm,
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_remove_community::dsl::mod_remove_community;
|
|
|
|
use crate::schema::mod_remove_community::dsl::mod_remove_community;
|
|
|
|
diesel::update(mod_remove_community.find(from_id))
|
|
|
|
diesel::update(mod_remove_community.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -209,31 +209,31 @@ impl Crud for ModBanFromCommunity {
|
|
|
|
type InsertForm = ModBanFromCommunityForm;
|
|
|
|
type InsertForm = ModBanFromCommunityForm;
|
|
|
|
type UpdateForm = ModBanFromCommunityForm;
|
|
|
|
type UpdateForm = ModBanFromCommunityForm;
|
|
|
|
type IdType = i32;
|
|
|
|
type IdType = i32;
|
|
|
|
async fn read(mut conn: impl DbConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
async fn read(mut conn: impl GetConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_ban_from_community::dsl::mod_ban_from_community;
|
|
|
|
use crate::schema::mod_ban_from_community::dsl::mod_ban_from_community;
|
|
|
|
mod_ban_from_community
|
|
|
|
mod_ban_from_community
|
|
|
|
.find(from_id)
|
|
|
|
.find(from_id)
|
|
|
|
.first::<Self>(&mut *conn)
|
|
|
|
.first::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn create(mut conn: impl DbConn, form: &ModBanFromCommunityForm) -> Result<Self, Error> {
|
|
|
|
async fn create(mut conn: impl GetConn, form: &ModBanFromCommunityForm) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_ban_from_community::dsl::mod_ban_from_community;
|
|
|
|
use crate::schema::mod_ban_from_community::dsl::mod_ban_from_community;
|
|
|
|
insert_into(mod_ban_from_community)
|
|
|
|
insert_into(mod_ban_from_community)
|
|
|
|
.values(form)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn update(
|
|
|
|
async fn update(
|
|
|
|
mut conn: impl DbConn,
|
|
|
|
mut conn: impl GetConn,
|
|
|
|
from_id: i32,
|
|
|
|
from_id: i32,
|
|
|
|
form: &ModBanFromCommunityForm,
|
|
|
|
form: &ModBanFromCommunityForm,
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_ban_from_community::dsl::mod_ban_from_community;
|
|
|
|
use crate::schema::mod_ban_from_community::dsl::mod_ban_from_community;
|
|
|
|
diesel::update(mod_ban_from_community.find(from_id))
|
|
|
|
diesel::update(mod_ban_from_community.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -243,24 +243,24 @@ impl Crud for ModBan {
|
|
|
|
type InsertForm = ModBanForm;
|
|
|
|
type InsertForm = ModBanForm;
|
|
|
|
type UpdateForm = ModBanForm;
|
|
|
|
type UpdateForm = ModBanForm;
|
|
|
|
type IdType = i32;
|
|
|
|
type IdType = i32;
|
|
|
|
async fn read(mut conn: impl DbConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
async fn read(mut conn: impl GetConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_ban::dsl::mod_ban;
|
|
|
|
use crate::schema::mod_ban::dsl::mod_ban;
|
|
|
|
mod_ban.find(from_id).first::<Self>(&mut *conn).await
|
|
|
|
mod_ban.find(from_id).first::<Self>(conn).await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn create(mut conn: impl DbConn, form: &ModBanForm) -> Result<Self, Error> {
|
|
|
|
async fn create(mut conn: impl GetConn, form: &ModBanForm) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_ban::dsl::mod_ban;
|
|
|
|
use crate::schema::mod_ban::dsl::mod_ban;
|
|
|
|
insert_into(mod_ban)
|
|
|
|
insert_into(mod_ban)
|
|
|
|
.values(form)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn update(mut conn: impl DbConn, from_id: i32, form: &ModBanForm) -> Result<Self, Error> {
|
|
|
|
async fn update(mut conn: impl GetConn, from_id: i32, form: &ModBanForm) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_ban::dsl::mod_ban;
|
|
|
|
use crate::schema::mod_ban::dsl::mod_ban;
|
|
|
|
diesel::update(mod_ban.find(from_id))
|
|
|
|
diesel::update(mod_ban.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -271,31 +271,31 @@ impl Crud for ModHideCommunity {
|
|
|
|
type UpdateForm = ModHideCommunityForm;
|
|
|
|
type UpdateForm = ModHideCommunityForm;
|
|
|
|
type IdType = i32;
|
|
|
|
type IdType = i32;
|
|
|
|
|
|
|
|
|
|
|
|
async fn read(mut conn: impl DbConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
async fn read(mut conn: impl GetConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_hide_community::dsl::mod_hide_community;
|
|
|
|
use crate::schema::mod_hide_community::dsl::mod_hide_community;
|
|
|
|
mod_hide_community
|
|
|
|
mod_hide_community
|
|
|
|
.find(from_id)
|
|
|
|
.find(from_id)
|
|
|
|
.first::<Self>(&mut *conn)
|
|
|
|
.first::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn create(mut conn: impl DbConn, form: &ModHideCommunityForm) -> Result<Self, Error> {
|
|
|
|
async fn create(mut conn: impl GetConn, form: &ModHideCommunityForm) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_hide_community::dsl::mod_hide_community;
|
|
|
|
use crate::schema::mod_hide_community::dsl::mod_hide_community;
|
|
|
|
insert_into(mod_hide_community)
|
|
|
|
insert_into(mod_hide_community)
|
|
|
|
.values(form)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn update(
|
|
|
|
async fn update(
|
|
|
|
mut conn: impl DbConn,
|
|
|
|
mut conn: impl GetConn,
|
|
|
|
from_id: i32,
|
|
|
|
from_id: i32,
|
|
|
|
form: &ModHideCommunityForm,
|
|
|
|
form: &ModHideCommunityForm,
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_hide_community::dsl::mod_hide_community;
|
|
|
|
use crate::schema::mod_hide_community::dsl::mod_hide_community;
|
|
|
|
diesel::update(mod_hide_community.find(from_id))
|
|
|
|
diesel::update(mod_hide_community.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -305,31 +305,31 @@ impl Crud for ModAddCommunity {
|
|
|
|
type InsertForm = ModAddCommunityForm;
|
|
|
|
type InsertForm = ModAddCommunityForm;
|
|
|
|
type UpdateForm = ModAddCommunityForm;
|
|
|
|
type UpdateForm = ModAddCommunityForm;
|
|
|
|
type IdType = i32;
|
|
|
|
type IdType = i32;
|
|
|
|
async fn read(mut conn: impl DbConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
async fn read(mut conn: impl GetConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_add_community::dsl::mod_add_community;
|
|
|
|
use crate::schema::mod_add_community::dsl::mod_add_community;
|
|
|
|
mod_add_community
|
|
|
|
mod_add_community
|
|
|
|
.find(from_id)
|
|
|
|
.find(from_id)
|
|
|
|
.first::<Self>(&mut *conn)
|
|
|
|
.first::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn create(mut conn: impl DbConn, form: &ModAddCommunityForm) -> Result<Self, Error> {
|
|
|
|
async fn create(mut conn: impl GetConn, form: &ModAddCommunityForm) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_add_community::dsl::mod_add_community;
|
|
|
|
use crate::schema::mod_add_community::dsl::mod_add_community;
|
|
|
|
insert_into(mod_add_community)
|
|
|
|
insert_into(mod_add_community)
|
|
|
|
.values(form)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn update(
|
|
|
|
async fn update(
|
|
|
|
mut conn: impl DbConn,
|
|
|
|
mut conn: impl GetConn,
|
|
|
|
from_id: i32,
|
|
|
|
from_id: i32,
|
|
|
|
form: &ModAddCommunityForm,
|
|
|
|
form: &ModAddCommunityForm,
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_add_community::dsl::mod_add_community;
|
|
|
|
use crate::schema::mod_add_community::dsl::mod_add_community;
|
|
|
|
diesel::update(mod_add_community.find(from_id))
|
|
|
|
diesel::update(mod_add_community.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -339,31 +339,31 @@ impl Crud for ModTransferCommunity {
|
|
|
|
type InsertForm = ModTransferCommunityForm;
|
|
|
|
type InsertForm = ModTransferCommunityForm;
|
|
|
|
type UpdateForm = ModTransferCommunityForm;
|
|
|
|
type UpdateForm = ModTransferCommunityForm;
|
|
|
|
type IdType = i32;
|
|
|
|
type IdType = i32;
|
|
|
|
async fn read(mut conn: impl DbConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
async fn read(mut conn: impl GetConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_transfer_community::dsl::mod_transfer_community;
|
|
|
|
use crate::schema::mod_transfer_community::dsl::mod_transfer_community;
|
|
|
|
mod_transfer_community
|
|
|
|
mod_transfer_community
|
|
|
|
.find(from_id)
|
|
|
|
.find(from_id)
|
|
|
|
.first::<Self>(&mut *conn)
|
|
|
|
.first::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn create(mut conn: impl DbConn, form: &ModTransferCommunityForm) -> Result<Self, Error> {
|
|
|
|
async fn create(mut conn: impl GetConn, form: &ModTransferCommunityForm) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_transfer_community::dsl::mod_transfer_community;
|
|
|
|
use crate::schema::mod_transfer_community::dsl::mod_transfer_community;
|
|
|
|
insert_into(mod_transfer_community)
|
|
|
|
insert_into(mod_transfer_community)
|
|
|
|
.values(form)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn update(
|
|
|
|
async fn update(
|
|
|
|
mut conn: impl DbConn,
|
|
|
|
mut conn: impl GetConn,
|
|
|
|
from_id: i32,
|
|
|
|
from_id: i32,
|
|
|
|
form: &ModTransferCommunityForm,
|
|
|
|
form: &ModTransferCommunityForm,
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_transfer_community::dsl::mod_transfer_community;
|
|
|
|
use crate::schema::mod_transfer_community::dsl::mod_transfer_community;
|
|
|
|
diesel::update(mod_transfer_community.find(from_id))
|
|
|
|
diesel::update(mod_transfer_community.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -373,24 +373,24 @@ impl Crud for ModAdd {
|
|
|
|
type InsertForm = ModAddForm;
|
|
|
|
type InsertForm = ModAddForm;
|
|
|
|
type UpdateForm = ModAddForm;
|
|
|
|
type UpdateForm = ModAddForm;
|
|
|
|
type IdType = i32;
|
|
|
|
type IdType = i32;
|
|
|
|
async fn read(mut conn: impl DbConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
async fn read(mut conn: impl GetConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_add::dsl::mod_add;
|
|
|
|
use crate::schema::mod_add::dsl::mod_add;
|
|
|
|
mod_add.find(from_id).first::<Self>(&mut *conn).await
|
|
|
|
mod_add.find(from_id).first::<Self>(conn).await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn create(mut conn: impl DbConn, form: &ModAddForm) -> Result<Self, Error> {
|
|
|
|
async fn create(mut conn: impl GetConn, form: &ModAddForm) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_add::dsl::mod_add;
|
|
|
|
use crate::schema::mod_add::dsl::mod_add;
|
|
|
|
insert_into(mod_add)
|
|
|
|
insert_into(mod_add)
|
|
|
|
.values(form)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn update(mut conn: impl DbConn, from_id: i32, form: &ModAddForm) -> Result<Self, Error> {
|
|
|
|
async fn update(mut conn: impl GetConn, from_id: i32, form: &ModAddForm) -> Result<Self, Error> {
|
|
|
|
use crate::schema::mod_add::dsl::mod_add;
|
|
|
|
use crate::schema::mod_add::dsl::mod_add;
|
|
|
|
diesel::update(mod_add.find(from_id))
|
|
|
|
diesel::update(mod_add.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -400,31 +400,31 @@ impl Crud for AdminPurgePerson {
|
|
|
|
type InsertForm = AdminPurgePersonForm;
|
|
|
|
type InsertForm = AdminPurgePersonForm;
|
|
|
|
type UpdateForm = AdminPurgePersonForm;
|
|
|
|
type UpdateForm = AdminPurgePersonForm;
|
|
|
|
type IdType = i32;
|
|
|
|
type IdType = i32;
|
|
|
|
async fn read(mut conn: impl DbConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
async fn read(mut conn: impl GetConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
use crate::schema::admin_purge_person::dsl::admin_purge_person;
|
|
|
|
use crate::schema::admin_purge_person::dsl::admin_purge_person;
|
|
|
|
admin_purge_person
|
|
|
|
admin_purge_person
|
|
|
|
.find(from_id)
|
|
|
|
.find(from_id)
|
|
|
|
.first::<Self>(&mut *conn)
|
|
|
|
.first::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn create(mut conn: impl DbConn, form: &Self::InsertForm) -> Result<Self, Error> {
|
|
|
|
async fn create(mut conn: impl GetConn, form: &Self::InsertForm) -> Result<Self, Error> {
|
|
|
|
use crate::schema::admin_purge_person::dsl::admin_purge_person;
|
|
|
|
use crate::schema::admin_purge_person::dsl::admin_purge_person;
|
|
|
|
insert_into(admin_purge_person)
|
|
|
|
insert_into(admin_purge_person)
|
|
|
|
.values(form)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn update(
|
|
|
|
async fn update(
|
|
|
|
mut conn: impl DbConn,
|
|
|
|
mut conn: impl GetConn,
|
|
|
|
from_id: i32,
|
|
|
|
from_id: i32,
|
|
|
|
form: &Self::InsertForm,
|
|
|
|
form: &Self::InsertForm,
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
use crate::schema::admin_purge_person::dsl::admin_purge_person;
|
|
|
|
use crate::schema::admin_purge_person::dsl::admin_purge_person;
|
|
|
|
diesel::update(admin_purge_person.find(from_id))
|
|
|
|
diesel::update(admin_purge_person.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -434,31 +434,31 @@ impl Crud for AdminPurgeCommunity {
|
|
|
|
type InsertForm = AdminPurgeCommunityForm;
|
|
|
|
type InsertForm = AdminPurgeCommunityForm;
|
|
|
|
type UpdateForm = AdminPurgeCommunityForm;
|
|
|
|
type UpdateForm = AdminPurgeCommunityForm;
|
|
|
|
type IdType = i32;
|
|
|
|
type IdType = i32;
|
|
|
|
async fn read(mut conn: impl DbConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
async fn read(mut conn: impl GetConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
use crate::schema::admin_purge_community::dsl::admin_purge_community;
|
|
|
|
use crate::schema::admin_purge_community::dsl::admin_purge_community;
|
|
|
|
admin_purge_community
|
|
|
|
admin_purge_community
|
|
|
|
.find(from_id)
|
|
|
|
.find(from_id)
|
|
|
|
.first::<Self>(&mut *conn)
|
|
|
|
.first::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn create(mut conn: impl DbConn, form: &Self::InsertForm) -> Result<Self, Error> {
|
|
|
|
async fn create(mut conn: impl GetConn, form: &Self::InsertForm) -> Result<Self, Error> {
|
|
|
|
use crate::schema::admin_purge_community::dsl::admin_purge_community;
|
|
|
|
use crate::schema::admin_purge_community::dsl::admin_purge_community;
|
|
|
|
insert_into(admin_purge_community)
|
|
|
|
insert_into(admin_purge_community)
|
|
|
|
.values(form)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn update(
|
|
|
|
async fn update(
|
|
|
|
mut conn: impl DbConn,
|
|
|
|
mut conn: impl GetConn,
|
|
|
|
from_id: i32,
|
|
|
|
from_id: i32,
|
|
|
|
form: &Self::InsertForm,
|
|
|
|
form: &Self::InsertForm,
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
use crate::schema::admin_purge_community::dsl::admin_purge_community;
|
|
|
|
use crate::schema::admin_purge_community::dsl::admin_purge_community;
|
|
|
|
diesel::update(admin_purge_community.find(from_id))
|
|
|
|
diesel::update(admin_purge_community.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -468,31 +468,31 @@ impl Crud for AdminPurgePost {
|
|
|
|
type InsertForm = AdminPurgePostForm;
|
|
|
|
type InsertForm = AdminPurgePostForm;
|
|
|
|
type UpdateForm = AdminPurgePostForm;
|
|
|
|
type UpdateForm = AdminPurgePostForm;
|
|
|
|
type IdType = i32;
|
|
|
|
type IdType = i32;
|
|
|
|
async fn read(mut conn: impl DbConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
async fn read(mut conn: impl GetConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
use crate::schema::admin_purge_post::dsl::admin_purge_post;
|
|
|
|
use crate::schema::admin_purge_post::dsl::admin_purge_post;
|
|
|
|
admin_purge_post
|
|
|
|
admin_purge_post
|
|
|
|
.find(from_id)
|
|
|
|
.find(from_id)
|
|
|
|
.first::<Self>(&mut *conn)
|
|
|
|
.first::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn create(mut conn: impl DbConn, form: &Self::InsertForm) -> Result<Self, Error> {
|
|
|
|
async fn create(mut conn: impl GetConn, form: &Self::InsertForm) -> Result<Self, Error> {
|
|
|
|
use crate::schema::admin_purge_post::dsl::admin_purge_post;
|
|
|
|
use crate::schema::admin_purge_post::dsl::admin_purge_post;
|
|
|
|
insert_into(admin_purge_post)
|
|
|
|
insert_into(admin_purge_post)
|
|
|
|
.values(form)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn update(
|
|
|
|
async fn update(
|
|
|
|
mut conn: impl DbConn,
|
|
|
|
mut conn: impl GetConn,
|
|
|
|
from_id: i32,
|
|
|
|
from_id: i32,
|
|
|
|
form: &Self::InsertForm,
|
|
|
|
form: &Self::InsertForm,
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
use crate::schema::admin_purge_post::dsl::admin_purge_post;
|
|
|
|
use crate::schema::admin_purge_post::dsl::admin_purge_post;
|
|
|
|
diesel::update(admin_purge_post.find(from_id))
|
|
|
|
diesel::update(admin_purge_post.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -502,31 +502,31 @@ impl Crud for AdminPurgeComment {
|
|
|
|
type InsertForm = AdminPurgeCommentForm;
|
|
|
|
type InsertForm = AdminPurgeCommentForm;
|
|
|
|
type UpdateForm = AdminPurgeCommentForm;
|
|
|
|
type UpdateForm = AdminPurgeCommentForm;
|
|
|
|
type IdType = i32;
|
|
|
|
type IdType = i32;
|
|
|
|
async fn read(mut conn: impl DbConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
async fn read(mut conn: impl GetConn, from_id: i32) -> Result<Self, Error> {
|
|
|
|
use crate::schema::admin_purge_comment::dsl::admin_purge_comment;
|
|
|
|
use crate::schema::admin_purge_comment::dsl::admin_purge_comment;
|
|
|
|
admin_purge_comment
|
|
|
|
admin_purge_comment
|
|
|
|
.find(from_id)
|
|
|
|
.find(from_id)
|
|
|
|
.first::<Self>(&mut *conn)
|
|
|
|
.first::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn create(mut conn: impl DbConn, form: &Self::InsertForm) -> Result<Self, Error> {
|
|
|
|
async fn create(mut conn: impl GetConn, form: &Self::InsertForm) -> Result<Self, Error> {
|
|
|
|
use crate::schema::admin_purge_comment::dsl::admin_purge_comment;
|
|
|
|
use crate::schema::admin_purge_comment::dsl::admin_purge_comment;
|
|
|
|
insert_into(admin_purge_comment)
|
|
|
|
insert_into(admin_purge_comment)
|
|
|
|
.values(form)
|
|
|
|
.values(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn update(
|
|
|
|
async fn update(
|
|
|
|
mut conn: impl DbConn,
|
|
|
|
mut conn: impl GetConn,
|
|
|
|
from_id: i32,
|
|
|
|
from_id: i32,
|
|
|
|
form: &Self::InsertForm,
|
|
|
|
form: &Self::InsertForm,
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
) -> Result<Self, Error> {
|
|
|
|
use crate::schema::admin_purge_comment::dsl::admin_purge_comment;
|
|
|
|
use crate::schema::admin_purge_comment::dsl::admin_purge_comment;
|
|
|
|
diesel::update(admin_purge_comment.find(from_id))
|
|
|
|
diesel::update(admin_purge_comment.find(from_id))
|
|
|
|
.set(form)
|
|
|
|
.set(form)
|
|
|
|
.get_result::<Self>(&mut *conn)
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -571,7 +571,7 @@ mod tests {
|
|
|
|
async fn test_crud() {
|
|
|
|
async fn test_crud() {
|
|
|
|
let mut conn = build_db_conn_for_tests().await;
|
|
|
|
let mut conn = build_db_conn_for_tests().await;
|
|
|
|
|
|
|
|
|
|
|
|
let inserted_instance = Instance::read_or_create(&mut *conn, "my_domain.tld".to_string())
|
|
|
|
let inserted_instance = Instance::read_or_create(conn, "my_domain.tld".to_string())
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
|
|
|
@ -581,7 +581,7 @@ mod tests {
|
|
|
|
.instance_id(inserted_instance.id)
|
|
|
|
.instance_id(inserted_instance.id)
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
let inserted_mod = Person::create(&mut *conn, &new_mod).await.unwrap();
|
|
|
|
let inserted_mod = Person::create(conn, &new_mod).await.unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
let new_person = PersonInsertForm::builder()
|
|
|
|
let new_person = PersonInsertForm::builder()
|
|
|
|
.name("jim2".into())
|
|
|
|
.name("jim2".into())
|
|
|
@ -589,7 +589,7 @@ mod tests {
|
|
|
|
.instance_id(inserted_instance.id)
|
|
|
|
.instance_id(inserted_instance.id)
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
let inserted_person = Person::create(&mut *conn, &new_person).await.unwrap();
|
|
|
|
let inserted_person = Person::create(conn, &new_person).await.unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
let new_community = CommunityInsertForm::builder()
|
|
|
|
let new_community = CommunityInsertForm::builder()
|
|
|
|
.name("mod_community".to_string())
|
|
|
|
.name("mod_community".to_string())
|
|
|
@ -598,7 +598,7 @@ mod tests {
|
|
|
|
.instance_id(inserted_instance.id)
|
|
|
|
.instance_id(inserted_instance.id)
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
let inserted_community = Community::create(&mut *conn, &new_community).await.unwrap();
|
|
|
|
let inserted_community = Community::create(conn, &new_community).await.unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
let new_post = PostInsertForm::builder()
|
|
|
|
let new_post = PostInsertForm::builder()
|
|
|
|
.name("A test post thweep".into())
|
|
|
|
.name("A test post thweep".into())
|
|
|
@ -606,7 +606,7 @@ mod tests {
|
|
|
|
.community_id(inserted_community.id)
|
|
|
|
.community_id(inserted_community.id)
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
let inserted_post = Post::create(&mut *conn, &new_post).await.unwrap();
|
|
|
|
let inserted_post = Post::create(conn, &new_post).await.unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
let comment_form = CommentInsertForm::builder()
|
|
|
|
let comment_form = CommentInsertForm::builder()
|
|
|
|
.content("A test comment".into())
|
|
|
|
.content("A test comment".into())
|
|
|
@ -614,7 +614,7 @@ mod tests {
|
|
|
|
.post_id(inserted_post.id)
|
|
|
|
.post_id(inserted_post.id)
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
let inserted_comment = Comment::create(&mut *conn, &comment_form, None)
|
|
|
|
let inserted_comment = Comment::create(conn, &comment_form, None)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
|
|
|
@ -627,10 +627,10 @@ mod tests {
|
|
|
|
reason: None,
|
|
|
|
reason: None,
|
|
|
|
removed: None,
|
|
|
|
removed: None,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let inserted_mod_remove_post = ModRemovePost::create(&mut *conn, &mod_remove_post_form)
|
|
|
|
let inserted_mod_remove_post = ModRemovePost::create(conn, &mod_remove_post_form)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
let read_mod_remove_post = ModRemovePost::read(&mut *conn, inserted_mod_remove_post.id)
|
|
|
|
let read_mod_remove_post = ModRemovePost::read(conn, inserted_mod_remove_post.id)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
let expected_mod_remove_post = ModRemovePost {
|
|
|
|
let expected_mod_remove_post = ModRemovePost {
|
|
|
@ -649,10 +649,10 @@ mod tests {
|
|
|
|
post_id: inserted_post.id,
|
|
|
|
post_id: inserted_post.id,
|
|
|
|
locked: None,
|
|
|
|
locked: None,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let inserted_mod_lock_post = ModLockPost::create(&mut *conn, &mod_lock_post_form)
|
|
|
|
let inserted_mod_lock_post = ModLockPost::create(conn, &mod_lock_post_form)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
let read_mod_lock_post = ModLockPost::read(&mut *conn, inserted_mod_lock_post.id)
|
|
|
|
let read_mod_lock_post = ModLockPost::read(conn, inserted_mod_lock_post.id)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
let expected_mod_lock_post = ModLockPost {
|
|
|
|
let expected_mod_lock_post = ModLockPost {
|
|
|
@ -671,10 +671,10 @@ mod tests {
|
|
|
|
featured: false,
|
|
|
|
featured: false,
|
|
|
|
is_featured_community: true,
|
|
|
|
is_featured_community: true,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let inserted_mod_feature_post = ModFeaturePost::create(&mut *conn, &mod_feature_post_form)
|
|
|
|
let inserted_mod_feature_post = ModFeaturePost::create(conn, &mod_feature_post_form)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
let read_mod_feature_post = ModFeaturePost::read(&mut *conn, inserted_mod_feature_post.id)
|
|
|
|
let read_mod_feature_post = ModFeaturePost::read(conn, inserted_mod_feature_post.id)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
let expected_mod_feature_post = ModFeaturePost {
|
|
|
|
let expected_mod_feature_post = ModFeaturePost {
|
|
|
@ -695,11 +695,11 @@ mod tests {
|
|
|
|
removed: None,
|
|
|
|
removed: None,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let inserted_mod_remove_comment =
|
|
|
|
let inserted_mod_remove_comment =
|
|
|
|
ModRemoveComment::create(&mut *conn, &mod_remove_comment_form)
|
|
|
|
ModRemoveComment::create(conn, &mod_remove_comment_form)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
let read_mod_remove_comment =
|
|
|
|
let read_mod_remove_comment =
|
|
|
|
ModRemoveComment::read(&mut *conn, inserted_mod_remove_comment.id)
|
|
|
|
ModRemoveComment::read(conn, inserted_mod_remove_comment.id)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
let expected_mod_remove_comment = ModRemoveComment {
|
|
|
|
let expected_mod_remove_comment = ModRemoveComment {
|
|
|
@ -721,11 +721,11 @@ mod tests {
|
|
|
|
expires: None,
|
|
|
|
expires: None,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let inserted_mod_remove_community =
|
|
|
|
let inserted_mod_remove_community =
|
|
|
|
ModRemoveCommunity::create(&mut *conn, &mod_remove_community_form)
|
|
|
|
ModRemoveCommunity::create(conn, &mod_remove_community_form)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
let read_mod_remove_community =
|
|
|
|
let read_mod_remove_community =
|
|
|
|
ModRemoveCommunity::read(&mut *conn, inserted_mod_remove_community.id)
|
|
|
|
ModRemoveCommunity::read(conn, inserted_mod_remove_community.id)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
let expected_mod_remove_community = ModRemoveCommunity {
|
|
|
|
let expected_mod_remove_community = ModRemoveCommunity {
|
|
|
@ -749,11 +749,11 @@ mod tests {
|
|
|
|
expires: None,
|
|
|
|
expires: None,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let inserted_mod_ban_from_community =
|
|
|
|
let inserted_mod_ban_from_community =
|
|
|
|
ModBanFromCommunity::create(&mut *conn, &mod_ban_from_community_form)
|
|
|
|
ModBanFromCommunity::create(conn, &mod_ban_from_community_form)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
let read_mod_ban_from_community =
|
|
|
|
let read_mod_ban_from_community =
|
|
|
|
ModBanFromCommunity::read(&mut *conn, inserted_mod_ban_from_community.id)
|
|
|
|
ModBanFromCommunity::read(conn, inserted_mod_ban_from_community.id)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
let expected_mod_ban_from_community = ModBanFromCommunity {
|
|
|
|
let expected_mod_ban_from_community = ModBanFromCommunity {
|
|
|
@ -776,8 +776,8 @@ mod tests {
|
|
|
|
banned: None,
|
|
|
|
banned: None,
|
|
|
|
expires: None,
|
|
|
|
expires: None,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let inserted_mod_ban = ModBan::create(&mut *conn, &mod_ban_form).await.unwrap();
|
|
|
|
let inserted_mod_ban = ModBan::create(conn, &mod_ban_form).await.unwrap();
|
|
|
|
let read_mod_ban = ModBan::read(&mut *conn, inserted_mod_ban.id).await.unwrap();
|
|
|
|
let read_mod_ban = ModBan::read(conn, inserted_mod_ban.id).await.unwrap();
|
|
|
|
let expected_mod_ban = ModBan {
|
|
|
|
let expected_mod_ban = ModBan {
|
|
|
|
id: inserted_mod_ban.id,
|
|
|
|
id: inserted_mod_ban.id,
|
|
|
|
mod_person_id: inserted_mod.id,
|
|
|
|
mod_person_id: inserted_mod.id,
|
|
|
@ -796,10 +796,10 @@ mod tests {
|
|
|
|
community_id: inserted_community.id,
|
|
|
|
community_id: inserted_community.id,
|
|
|
|
removed: None,
|
|
|
|
removed: None,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let inserted_mod_add_community = ModAddCommunity::create(&mut *conn, &mod_add_community_form)
|
|
|
|
let inserted_mod_add_community = ModAddCommunity::create(conn, &mod_add_community_form)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
let read_mod_add_community = ModAddCommunity::read(&mut *conn, inserted_mod_add_community.id)
|
|
|
|
let read_mod_add_community = ModAddCommunity::read(conn, inserted_mod_add_community.id)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
let expected_mod_add_community = ModAddCommunity {
|
|
|
|
let expected_mod_add_community = ModAddCommunity {
|
|
|
@ -818,8 +818,8 @@ mod tests {
|
|
|
|
other_person_id: inserted_person.id,
|
|
|
|
other_person_id: inserted_person.id,
|
|
|
|
removed: None,
|
|
|
|
removed: None,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let inserted_mod_add = ModAdd::create(&mut *conn, &mod_add_form).await.unwrap();
|
|
|
|
let inserted_mod_add = ModAdd::create(conn, &mod_add_form).await.unwrap();
|
|
|
|
let read_mod_add = ModAdd::read(&mut *conn, inserted_mod_add.id).await.unwrap();
|
|
|
|
let read_mod_add = ModAdd::read(conn, inserted_mod_add.id).await.unwrap();
|
|
|
|
let expected_mod_add = ModAdd {
|
|
|
|
let expected_mod_add = ModAdd {
|
|
|
|
id: inserted_mod_add.id,
|
|
|
|
id: inserted_mod_add.id,
|
|
|
|
mod_person_id: inserted_mod.id,
|
|
|
|
mod_person_id: inserted_mod.id,
|
|
|
@ -828,18 +828,18 @@ mod tests {
|
|
|
|
when_: inserted_mod_add.when_,
|
|
|
|
when_: inserted_mod_add.when_,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Comment::delete(&mut *conn, inserted_comment.id)
|
|
|
|
Comment::delete(conn, inserted_comment.id)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
Post::delete(&mut *conn, inserted_post.id).await.unwrap();
|
|
|
|
Post::delete(conn, inserted_post.id).await.unwrap();
|
|
|
|
Community::delete(&mut *conn, inserted_community.id)
|
|
|
|
Community::delete(conn, inserted_community.id)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
Person::delete(&mut *conn, inserted_person.id)
|
|
|
|
Person::delete(conn, inserted_person.id)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
Person::delete(&mut *conn, inserted_mod.id).await.unwrap();
|
|
|
|
Person::delete(conn, inserted_mod.id).await.unwrap();
|
|
|
|
Instance::delete(&mut *conn, inserted_instance.id)
|
|
|
|
Instance::delete(conn, inserted_instance.id)
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
|
|
|
|