mirror of https://github.com/LemmyNet/lemmy.git
parent
7ed20f5f71
commit
25a27165a8
|
@ -152,7 +152,7 @@ where ca.comment_id = c.id"
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for Comment {
|
impl Crud for Comment {
|
||||||
type InsertForm = CommentInsertForm;
|
type InsertForm = CommentInsertForm;
|
||||||
type UpdateForm = CommentUpdateForm;
|
type UpdateForm = CommentUpdateForm;
|
||||||
type IdType = CommentId;
|
type IdType = CommentId;
|
||||||
|
@ -163,17 +163,14 @@ impl<'a> Crud<'a> for Comment {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is unimplemented, use [[Comment::create]]
|
/// This is unimplemented, use [[Comment::create]]
|
||||||
async fn create(
|
async fn create(_pool: &mut DbPool<'_>, _comment_form: &Self::InsertForm) -> Result<Self, Error> {
|
||||||
_pool: &mut DbPool<'_>,
|
|
||||||
_comment_form: &'a Self::InsertForm,
|
|
||||||
) -> Result<Self, Error> {
|
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
comment_id: CommentId,
|
comment_id: CommentId,
|
||||||
comment_form: &'a Self::UpdateForm,
|
comment_form: &Self::UpdateForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(comment.find(comment_id))
|
diesel::update(comment.find(comment_id))
|
||||||
|
|
|
@ -9,14 +9,14 @@ use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for CommentReply {
|
impl Crud for CommentReply {
|
||||||
type InsertForm = CommentReplyInsertForm;
|
type InsertForm = CommentReplyInsertForm;
|
||||||
type UpdateForm = CommentReplyUpdateForm;
|
type UpdateForm = CommentReplyUpdateForm;
|
||||||
type IdType = CommentReplyId;
|
type IdType = CommentReplyId;
|
||||||
|
|
||||||
async fn create(
|
async fn create(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
comment_reply_form: &'a Self::InsertForm,
|
comment_reply_form: &Self::InsertForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ impl<'a> Crud<'a> for CommentReply {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
comment_reply_id: CommentReplyId,
|
comment_reply_id: CommentReplyId,
|
||||||
comment_reply_form: &'a Self::UpdateForm,
|
comment_reply_form: &Self::UpdateForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(comment_reply.find(comment_reply_id))
|
diesel::update(comment_reply.find(comment_reply_id))
|
||||||
|
|
|
@ -23,7 +23,7 @@ use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for Community {
|
impl Crud for Community {
|
||||||
type InsertForm = CommunityInsertForm;
|
type InsertForm = CommunityInsertForm;
|
||||||
type UpdateForm = CommunityUpdateForm;
|
type UpdateForm = CommunityUpdateForm;
|
||||||
type IdType = CommunityId;
|
type IdType = CommunityId;
|
||||||
|
@ -35,7 +35,7 @@ impl<'a> Crud<'a> for Community {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||||
let is_new_community = match &form.actor_id {
|
let is_new_community = match &form.actor_id {
|
||||||
Some(id) => Community::read_from_apub_id(pool, id).await?.is_none(),
|
Some(id) => Community::read_from_apub_id(pool, id).await?.is_none(),
|
||||||
None => true,
|
None => true,
|
||||||
|
@ -62,7 +62,7 @@ impl<'a> Crud<'a> for Community {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
community_id: CommunityId,
|
community_id: CommunityId,
|
||||||
form: &'a Self::UpdateForm,
|
form: &Self::UpdateForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(community::table.find(community_id))
|
diesel::update(community::table.find(community_id))
|
||||||
|
|
|
@ -65,7 +65,7 @@ impl LocalUser {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for LocalUser {
|
impl Crud for LocalUser {
|
||||||
type InsertForm = LocalUserInsertForm;
|
type InsertForm = LocalUserInsertForm;
|
||||||
type UpdateForm = LocalUserUpdateForm;
|
type UpdateForm = LocalUserUpdateForm;
|
||||||
type IdType = LocalUserId;
|
type IdType = LocalUserId;
|
||||||
|
@ -76,7 +76,7 @@ impl<'a> Crud<'a> for LocalUser {
|
||||||
.execute(conn)
|
.execute(conn)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
let mut form_with_encrypted_password = form.clone();
|
let mut form_with_encrypted_password = form.clone();
|
||||||
let password_hash =
|
let password_hash =
|
||||||
|
@ -103,7 +103,7 @@ impl<'a> Crud<'a> for LocalUser {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
local_user_id: LocalUserId,
|
local_user_id: LocalUserId,
|
||||||
form: &'a Self::UpdateForm,
|
form: &Self::UpdateForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(local_user.find(local_user_id))
|
diesel::update(local_user.find(local_user_id))
|
||||||
|
|
|
@ -38,12 +38,12 @@ use diesel::{dsl::insert_into, result::Error, QueryDsl};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> 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 create(pool: &mut DbPool<'_>, form: &'a ModRemovePostForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_remove_post)
|
insert_into(mod_remove_post)
|
||||||
|
@ -55,7 +55,7 @@ impl<'a> Crud<'a> for ModRemovePost {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
from_id: i32,
|
from_id: i32,
|
||||||
form: &'a 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
@ -67,12 +67,12 @@ impl<'a> Crud<'a> for ModRemovePost {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for ModLockPost {
|
impl Crud for ModLockPost {
|
||||||
type InsertForm = ModLockPostForm;
|
type InsertForm = ModLockPostForm;
|
||||||
type UpdateForm = ModLockPostForm;
|
type UpdateForm = ModLockPostForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a ModLockPostForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_lock_post)
|
insert_into(mod_lock_post)
|
||||||
|
@ -84,7 +84,7 @@ impl<'a> Crud<'a> for ModLockPost {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
from_id: i32,
|
from_id: i32,
|
||||||
form: &'a 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
@ -96,12 +96,12 @@ impl<'a> Crud<'a> for ModLockPost {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for ModFeaturePost {
|
impl Crud for ModFeaturePost {
|
||||||
type InsertForm = ModFeaturePostForm;
|
type InsertForm = ModFeaturePostForm;
|
||||||
type UpdateForm = ModFeaturePostForm;
|
type UpdateForm = ModFeaturePostForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a ModFeaturePostForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_feature_post)
|
insert_into(mod_feature_post)
|
||||||
|
@ -113,7 +113,7 @@ impl<'a> Crud<'a> for ModFeaturePost {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
from_id: i32,
|
from_id: i32,
|
||||||
form: &'a 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
@ -125,12 +125,12 @@ impl<'a> Crud<'a> for ModFeaturePost {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for ModRemoveComment {
|
impl Crud for ModRemoveComment {
|
||||||
type InsertForm = ModRemoveCommentForm;
|
type InsertForm = ModRemoveCommentForm;
|
||||||
type UpdateForm = ModRemoveCommentForm;
|
type UpdateForm = ModRemoveCommentForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a ModRemoveCommentForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_remove_comment)
|
insert_into(mod_remove_comment)
|
||||||
|
@ -142,7 +142,7 @@ impl<'a> Crud<'a> for ModRemoveComment {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
from_id: i32,
|
from_id: i32,
|
||||||
form: &'a 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
@ -154,12 +154,12 @@ impl<'a> Crud<'a> for ModRemoveComment {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for ModRemoveCommunity {
|
impl Crud for ModRemoveCommunity {
|
||||||
type InsertForm = ModRemoveCommunityForm;
|
type InsertForm = ModRemoveCommunityForm;
|
||||||
type UpdateForm = ModRemoveCommunityForm;
|
type UpdateForm = ModRemoveCommunityForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a ModRemoveCommunityForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_remove_community)
|
insert_into(mod_remove_community)
|
||||||
|
@ -171,7 +171,7 @@ impl<'a> Crud<'a> for ModRemoveCommunity {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
from_id: i32,
|
from_id: i32,
|
||||||
form: &'a 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
@ -183,12 +183,12 @@ impl<'a> Crud<'a> for ModRemoveCommunity {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for ModBanFromCommunity {
|
impl Crud for ModBanFromCommunity {
|
||||||
type InsertForm = ModBanFromCommunityForm;
|
type InsertForm = ModBanFromCommunityForm;
|
||||||
type UpdateForm = ModBanFromCommunityForm;
|
type UpdateForm = ModBanFromCommunityForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a ModBanFromCommunityForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_ban_from_community)
|
insert_into(mod_ban_from_community)
|
||||||
|
@ -200,7 +200,7 @@ impl<'a> Crud<'a> for ModBanFromCommunity {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
from_id: i32,
|
from_id: i32,
|
||||||
form: &'a 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
@ -212,12 +212,12 @@ impl<'a> Crud<'a> for ModBanFromCommunity {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for ModBan {
|
impl Crud for ModBan {
|
||||||
type InsertForm = ModBanForm;
|
type InsertForm = ModBanForm;
|
||||||
type UpdateForm = ModBanForm;
|
type UpdateForm = ModBanForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a ModBanForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &ModBanForm) -> Result<Self, Error> {
|
||||||
use crate::schema::mod_ban::dsl::mod_ban;
|
use crate::schema::mod_ban::dsl::mod_ban;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_ban)
|
insert_into(mod_ban)
|
||||||
|
@ -226,11 +226,7 @@ impl<'a> Crud<'a> for ModBan {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update(
|
async fn update(pool: &mut DbPool<'_>, from_id: i32, form: &ModBanForm) -> Result<Self, Error> {
|
||||||
pool: &mut DbPool<'_>,
|
|
||||||
from_id: i32,
|
|
||||||
form: &'a ModBanForm,
|
|
||||||
) -> Result<Self, Error> {
|
|
||||||
use crate::schema::mod_ban::dsl::mod_ban;
|
use crate::schema::mod_ban::dsl::mod_ban;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(mod_ban.find(from_id))
|
diesel::update(mod_ban.find(from_id))
|
||||||
|
@ -241,12 +237,12 @@ impl<'a> Crud<'a> for ModBan {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for ModHideCommunity {
|
impl Crud for ModHideCommunity {
|
||||||
type InsertForm = ModHideCommunityForm;
|
type InsertForm = ModHideCommunityForm;
|
||||||
type UpdateForm = ModHideCommunityForm;
|
type UpdateForm = ModHideCommunityForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a ModHideCommunityForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_hide_community)
|
insert_into(mod_hide_community)
|
||||||
|
@ -258,7 +254,7 @@ impl<'a> Crud<'a> for ModHideCommunity {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
from_id: i32,
|
from_id: i32,
|
||||||
form: &'a 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
@ -270,12 +266,12 @@ impl<'a> Crud<'a> for ModHideCommunity {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for ModAddCommunity {
|
impl Crud for ModAddCommunity {
|
||||||
type InsertForm = ModAddCommunityForm;
|
type InsertForm = ModAddCommunityForm;
|
||||||
type UpdateForm = ModAddCommunityForm;
|
type UpdateForm = ModAddCommunityForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a ModAddCommunityForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_add_community)
|
insert_into(mod_add_community)
|
||||||
|
@ -287,7 +283,7 @@ impl<'a> Crud<'a> for ModAddCommunity {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
from_id: i32,
|
from_id: i32,
|
||||||
form: &'a 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
@ -299,15 +295,12 @@ impl<'a> Crud<'a> for ModAddCommunity {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for ModTransferCommunity {
|
impl Crud for ModTransferCommunity {
|
||||||
type InsertForm = ModTransferCommunityForm;
|
type InsertForm = ModTransferCommunityForm;
|
||||||
type UpdateForm = ModTransferCommunityForm;
|
type UpdateForm = ModTransferCommunityForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(
|
async fn create(pool: &mut DbPool<'_>, form: &ModTransferCommunityForm) -> Result<Self, Error> {
|
||||||
pool: &mut DbPool<'_>,
|
|
||||||
form: &'a ModTransferCommunityForm,
|
|
||||||
) -> Result<Self, Error> {
|
|
||||||
use crate::schema::mod_transfer_community::dsl::mod_transfer_community;
|
use crate::schema::mod_transfer_community::dsl::mod_transfer_community;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_transfer_community)
|
insert_into(mod_transfer_community)
|
||||||
|
@ -319,7 +312,7 @@ impl<'a> Crud<'a> for ModTransferCommunity {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
from_id: i32,
|
from_id: i32,
|
||||||
form: &'a 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
@ -331,12 +324,12 @@ impl<'a> Crud<'a> for ModTransferCommunity {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for ModAdd {
|
impl Crud for ModAdd {
|
||||||
type InsertForm = ModAddForm;
|
type InsertForm = ModAddForm;
|
||||||
type UpdateForm = ModAddForm;
|
type UpdateForm = ModAddForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a ModAddForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &ModAddForm) -> Result<Self, Error> {
|
||||||
use crate::schema::mod_add::dsl::mod_add;
|
use crate::schema::mod_add::dsl::mod_add;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(mod_add)
|
insert_into(mod_add)
|
||||||
|
@ -345,11 +338,7 @@ impl<'a> Crud<'a> for ModAdd {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update(
|
async fn update(pool: &mut DbPool<'_>, from_id: i32, form: &ModAddForm) -> Result<Self, Error> {
|
||||||
pool: &mut DbPool<'_>,
|
|
||||||
from_id: i32,
|
|
||||||
form: &'a ModAddForm,
|
|
||||||
) -> Result<Self, Error> {
|
|
||||||
use crate::schema::mod_add::dsl::mod_add;
|
use crate::schema::mod_add::dsl::mod_add;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(mod_add.find(from_id))
|
diesel::update(mod_add.find(from_id))
|
||||||
|
@ -360,12 +349,12 @@ impl<'a> Crud<'a> for ModAdd {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for AdminPurgePerson {
|
impl Crud for AdminPurgePerson {
|
||||||
type InsertForm = AdminPurgePersonForm;
|
type InsertForm = AdminPurgePersonForm;
|
||||||
type UpdateForm = AdminPurgePersonForm;
|
type UpdateForm = AdminPurgePersonForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(admin_purge_person)
|
insert_into(admin_purge_person)
|
||||||
|
@ -377,7 +366,7 @@ impl<'a> Crud<'a> for AdminPurgePerson {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
from_id: i32,
|
from_id: i32,
|
||||||
form: &'a 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
@ -389,12 +378,12 @@ impl<'a> Crud<'a> for AdminPurgePerson {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for AdminPurgeCommunity {
|
impl Crud for AdminPurgeCommunity {
|
||||||
type InsertForm = AdminPurgeCommunityForm;
|
type InsertForm = AdminPurgeCommunityForm;
|
||||||
type UpdateForm = AdminPurgeCommunityForm;
|
type UpdateForm = AdminPurgeCommunityForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(admin_purge_community)
|
insert_into(admin_purge_community)
|
||||||
|
@ -406,7 +395,7 @@ impl<'a> Crud<'a> for AdminPurgeCommunity {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
from_id: i32,
|
from_id: i32,
|
||||||
form: &'a 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
@ -418,12 +407,12 @@ impl<'a> Crud<'a> for AdminPurgeCommunity {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for AdminPurgePost {
|
impl Crud for AdminPurgePost {
|
||||||
type InsertForm = AdminPurgePostForm;
|
type InsertForm = AdminPurgePostForm;
|
||||||
type UpdateForm = AdminPurgePostForm;
|
type UpdateForm = AdminPurgePostForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(admin_purge_post)
|
insert_into(admin_purge_post)
|
||||||
|
@ -435,7 +424,7 @@ impl<'a> Crud<'a> for AdminPurgePost {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
from_id: i32,
|
from_id: i32,
|
||||||
form: &'a 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
@ -447,12 +436,12 @@ impl<'a> Crud<'a> for AdminPurgePost {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for AdminPurgeComment {
|
impl Crud for AdminPurgeComment {
|
||||||
type InsertForm = AdminPurgeCommentForm;
|
type InsertForm = AdminPurgeCommentForm;
|
||||||
type UpdateForm = AdminPurgeCommentForm;
|
type UpdateForm = AdminPurgeCommentForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(admin_purge_comment)
|
insert_into(admin_purge_comment)
|
||||||
|
@ -464,7 +453,7 @@ impl<'a> Crud<'a> for AdminPurgeComment {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
from_id: i32,
|
from_id: i32,
|
||||||
form: &'a 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;
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
|
|
@ -20,15 +20,12 @@ use diesel_async::RunQueryDsl;
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for PasswordResetRequest {
|
impl Crud for PasswordResetRequest {
|
||||||
type InsertForm = PasswordResetRequestForm;
|
type InsertForm = PasswordResetRequestForm;
|
||||||
type UpdateForm = PasswordResetRequestForm;
|
type UpdateForm = PasswordResetRequestForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(
|
async fn create(pool: &mut DbPool<'_>, form: &PasswordResetRequestForm) -> Result<Self, Error> {
|
||||||
pool: &mut DbPool<'_>,
|
|
||||||
form: &'a PasswordResetRequestForm,
|
|
||||||
) -> Result<Self, Error> {
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(password_reset_request)
|
insert_into(password_reset_request)
|
||||||
.values(form)
|
.values(form)
|
||||||
|
@ -38,7 +35,7 @@ impl<'a> Crud<'a> for PasswordResetRequest {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
password_reset_request_id: i32,
|
password_reset_request_id: i32,
|
||||||
form: &'a PasswordResetRequestForm,
|
form: &PasswordResetRequestForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(password_reset_request.find(password_reset_request_id))
|
diesel::update(password_reset_request.find(password_reset_request_id))
|
||||||
|
|
|
@ -15,7 +15,7 @@ use diesel::{dsl::insert_into, result::Error, ExpressionMethods, JoinOnDsl, Quer
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for Person {
|
impl Crud for Person {
|
||||||
type InsertForm = PersonInsertForm;
|
type InsertForm = PersonInsertForm;
|
||||||
type UpdateForm = PersonUpdateForm;
|
type UpdateForm = PersonUpdateForm;
|
||||||
type IdType = PersonId;
|
type IdType = PersonId;
|
||||||
|
@ -34,7 +34,7 @@ impl<'a> Crud<'a> for Person {
|
||||||
.execute(conn)
|
.execute(conn)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a PersonInsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &PersonInsertForm) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(person::table)
|
insert_into(person::table)
|
||||||
.values(form)
|
.values(form)
|
||||||
|
@ -44,7 +44,7 @@ impl<'a> Crud<'a> for Person {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
person_id: PersonId,
|
person_id: PersonId,
|
||||||
form: &'a PersonUpdateForm,
|
form: &PersonUpdateForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(person::table.find(person_id))
|
diesel::update(person::table.find(person_id))
|
||||||
|
|
|
@ -9,14 +9,14 @@ use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for PersonMention {
|
impl Crud for PersonMention {
|
||||||
type InsertForm = PersonMentionInsertForm;
|
type InsertForm = PersonMentionInsertForm;
|
||||||
type UpdateForm = PersonMentionUpdateForm;
|
type UpdateForm = PersonMentionUpdateForm;
|
||||||
type IdType = PersonMentionId;
|
type IdType = PersonMentionId;
|
||||||
|
|
||||||
async fn create(
|
async fn create(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
person_mention_form: &'a Self::InsertForm,
|
person_mention_form: &Self::InsertForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
// since the return here isnt utilized, we dont need to do an update
|
// since the return here isnt utilized, we dont need to do an update
|
||||||
|
@ -33,7 +33,7 @@ impl<'a> Crud<'a> for PersonMention {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
person_mention_id: PersonMentionId,
|
person_mention_id: PersonMentionId,
|
||||||
person_mention_form: &'a Self::UpdateForm,
|
person_mention_form: &Self::UpdateForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(person_mention.find(person_mention_id))
|
diesel::update(person_mention.find(person_mention_id))
|
||||||
|
|
|
@ -34,7 +34,7 @@ use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl, TextE
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for Post {
|
impl Crud for Post {
|
||||||
type InsertForm = PostInsertForm;
|
type InsertForm = PostInsertForm;
|
||||||
type UpdateForm = PostUpdateForm;
|
type UpdateForm = PostUpdateForm;
|
||||||
type IdType = PostId;
|
type IdType = PostId;
|
||||||
|
@ -44,7 +44,7 @@ impl<'a> Crud<'a> for Post {
|
||||||
diesel::delete(post.find(post_id)).execute(conn).await
|
diesel::delete(post.find(post_id)).execute(conn).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(post)
|
insert_into(post)
|
||||||
.values(form)
|
.values(form)
|
||||||
|
@ -58,7 +58,7 @@ impl<'a> Crud<'a> for Post {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
post_id: PostId,
|
post_id: PostId,
|
||||||
new_post: &'a Self::UpdateForm,
|
new_post: &Self::UpdateForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(post.find(post_id))
|
diesel::update(post.find(post_id))
|
||||||
|
|
|
@ -11,12 +11,12 @@ use lemmy_utils::error::LemmyError;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for PrivateMessage {
|
impl Crud for PrivateMessage {
|
||||||
type InsertForm = PrivateMessageInsertForm;
|
type InsertForm = PrivateMessageInsertForm;
|
||||||
type UpdateForm = PrivateMessageUpdateForm;
|
type UpdateForm = PrivateMessageUpdateForm;
|
||||||
type IdType = PrivateMessageId;
|
type IdType = PrivateMessageId;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(private_message)
|
insert_into(private_message)
|
||||||
.values(form)
|
.values(form)
|
||||||
|
@ -30,7 +30,7 @@ impl<'a> Crud<'a> for PrivateMessage {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
private_message_id: PrivateMessageId,
|
private_message_id: PrivateMessageId,
|
||||||
form: &'a Self::UpdateForm,
|
form: &Self::UpdateForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(private_message.find(private_message_id))
|
diesel::update(private_message.find(private_message_id))
|
||||||
|
|
|
@ -13,12 +13,12 @@ use diesel::{insert_into, result::Error, ExpressionMethods, QueryDsl};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for RegistrationApplication {
|
impl Crud for RegistrationApplication {
|
||||||
type InsertForm = RegistrationApplicationInsertForm;
|
type InsertForm = RegistrationApplicationInsertForm;
|
||||||
type UpdateForm = RegistrationApplicationUpdateForm;
|
type UpdateForm = RegistrationApplicationUpdateForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
insert_into(registration_application)
|
insert_into(registration_application)
|
||||||
.values(form)
|
.values(form)
|
||||||
|
@ -29,7 +29,7 @@ impl<'a> Crud<'a> for RegistrationApplication {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
id_: Self::IdType,
|
id_: Self::IdType,
|
||||||
form: &'a Self::UpdateForm,
|
form: &Self::UpdateForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(registration_application.find(id_))
|
diesel::update(registration_application.find(id_))
|
||||||
|
|
|
@ -13,7 +13,7 @@ use diesel_async::RunQueryDsl;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> Crud<'a> for Site {
|
impl Crud for Site {
|
||||||
type InsertForm = SiteInsertForm;
|
type InsertForm = SiteInsertForm;
|
||||||
type UpdateForm = SiteUpdateForm;
|
type UpdateForm = SiteUpdateForm;
|
||||||
type IdType = SiteId;
|
type IdType = SiteId;
|
||||||
|
@ -37,7 +37,7 @@ impl<'a> Crud<'a> for Site {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||||
let is_new_site = match &form.actor_id {
|
let is_new_site = match &form.actor_id {
|
||||||
Some(id_) => Site::read_from_apub_id(pool, id_).await?.is_none(),
|
Some(id_) => Site::read_from_apub_id(pool, id_).await?.is_none(),
|
||||||
None => true,
|
None => true,
|
||||||
|
@ -64,7 +64,7 @@ impl<'a> Crud<'a> for Site {
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
site_id: SiteId,
|
site_id: SiteId,
|
||||||
new_site: &'a Self::UpdateForm,
|
new_site: &Self::UpdateForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::update(site.find(site_id))
|
diesel::update(site.find(site_id))
|
||||||
|
|
|
@ -26,13 +26,13 @@ LimitDsl + Send + Sized + 'static,
|
||||||
<<Self::Table as Table>::PrimaryKey as Expression>::SqlType: SqlType,
|
<<Self::Table as Table>::PrimaryKey as Expression>::SqlType: SqlType,
|
||||||
<Self::Table as Table>::PrimaryKey: ExpressionMethods + Send + Sized + 'static,*/
|
<Self::Table as Table>::PrimaryKey: ExpressionMethods + Send + Sized + 'static,*/
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait Crud<'a>
|
pub trait Crud
|
||||||
where
|
where
|
||||||
Self: HasTable + Sized,
|
Self: HasTable + Sized,
|
||||||
Self::Table: FindDsl<Self::IdType> + 'static,
|
Self::Table: FindDsl<Self::IdType> + 'static,
|
||||||
dsl::Find<Self::Table, Self::IdType>: LimitDsl + Send,
|
dsl::Find<Self::Table, Self::IdType>: LimitDsl + Send,
|
||||||
for<'query> dsl::Limit<dsl::Find<Self::Table, Self::IdType>>:
|
for<'a> dsl::Limit<dsl::Find<Self::Table, Self::IdType>>:
|
||||||
Send + LoadQuery<'query, AsyncPgConnection, Self> + 'query,
|
Send + LoadQuery<'a, AsyncPgConnection, Self> + 'a,
|
||||||
<<Self as HasTable>::Table as Table>::PrimaryKey: ExpressionMethods + Send,
|
<<Self as HasTable>::Table as Table>::PrimaryKey: ExpressionMethods + Send,
|
||||||
<<<Self as HasTable>::Table as Table>::PrimaryKey as Expression>::SqlType:
|
<<<Self as HasTable>::Table as Table>::PrimaryKey as Expression>::SqlType:
|
||||||
SqlType + TypedExpressionType,
|
SqlType + TypedExpressionType,
|
||||||
|
@ -48,7 +48,7 @@ where
|
||||||
+ Sized
|
+ Sized
|
||||||
+ Send
|
+ Send
|
||||||
+ AsExpression<<<Self::Table as Table>::PrimaryKey as Expression>::SqlType>;
|
+ AsExpression<<<Self::Table as Table>::PrimaryKey as Expression>::SqlType>;
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &'a Self::InsertForm) -> Result<Self, Error>;
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error>;
|
||||||
/*{
|
/*{
|
||||||
let query = insert_into(Self::table()).values(form);
|
let query = insert_into(Self::table()).values(form);
|
||||||
let conn = &mut *get_conn(pool).await?;
|
let conn = &mut *get_conn(pool).await?;
|
||||||
|
@ -63,7 +63,7 @@ where
|
||||||
async fn update(
|
async fn update(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
id: Self::IdType,
|
id: Self::IdType,
|
||||||
form: &'a Self::UpdateForm,
|
form: &Self::UpdateForm,
|
||||||
) -> Result<Self, Error>;
|
) -> Result<Self, Error>;
|
||||||
/*{
|
/*{
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
|
Loading…
Reference in New Issue