mirror of
https://github.com/LemmyNet/lemmy
synced 2024-11-22 12:33:09 +00:00
Return to earlier thing
Revert "Add GetConn trait"
This reverts commit ab4e94aea5
.
This commit is contained in:
parent
a5a1478943
commit
23accf7e4f
82 changed files with 706 additions and 1091 deletions
|
@ -28,7 +28,7 @@ impl LemmyContext {
|
|||
rate_limit_cell,
|
||||
}
|
||||
}
|
||||
pub fn pool(&self) -> impl GetConn {
|
||||
pub fn pool(&self) -> &DbPool {
|
||||
&self.pool
|
||||
}
|
||||
pub fn client(&self) -> &ClientWithMiddleware {
|
||||
|
|
|
@ -24,7 +24,7 @@ use lemmy_db_schema::{
|
|||
registration_application::RegistrationApplication,
|
||||
},
|
||||
traits::{Crud, Readable},
|
||||
utils::{DbPool, GetConn},
|
||||
utils::DbPool,
|
||||
RegistrationMode,
|
||||
};
|
||||
use lemmy_db_views::{comment_view::CommentQuery, structs::LocalUserView};
|
||||
|
@ -50,7 +50,7 @@ use url::{ParseError, Url};
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn is_mod_or_admin(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
person_id: PersonId,
|
||||
community_id: CommunityId,
|
||||
) -> Result<(), LemmyError> {
|
||||
|
@ -63,7 +63,7 @@ pub async fn is_mod_or_admin(
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn is_mod_or_admin_opt(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
local_user_view: Option<&LocalUserView>,
|
||||
community_id: Option<CommunityId>,
|
||||
) -> Result<(), LemmyError> {
|
||||
|
@ -101,7 +101,7 @@ pub fn is_top_mod(
|
|||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn get_post(post_id: PostId, mut pool: &mut impl GetConn) -> Result<Post, LemmyError> {
|
||||
pub async fn get_post(post_id: PostId, pool: &DbPool) -> Result<Post, LemmyError> {
|
||||
Post::read(pool, post_id)
|
||||
.await
|
||||
.map_err(|e| LemmyError::from_error_message(e, "couldnt_find_post"))
|
||||
|
@ -111,7 +111,7 @@ pub async fn get_post(post_id: PostId, mut pool: &mut impl GetConn) -> Result<Po
|
|||
pub async fn mark_post_as_read(
|
||||
person_id: PersonId,
|
||||
post_id: PostId,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
) -> Result<PostRead, LemmyError> {
|
||||
let post_read_form = PostReadForm { post_id, person_id };
|
||||
|
||||
|
@ -124,7 +124,7 @@ pub async fn mark_post_as_read(
|
|||
pub async fn mark_post_as_unread(
|
||||
person_id: PersonId,
|
||||
post_id: PostId,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
) -> Result<usize, LemmyError> {
|
||||
let post_read_form = PostReadForm { post_id, person_id };
|
||||
|
||||
|
@ -197,7 +197,7 @@ pub fn check_user_valid(
|
|||
pub async fn check_community_ban(
|
||||
person_id: PersonId,
|
||||
community_id: CommunityId,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
) -> Result<(), LemmyError> {
|
||||
let is_banned = CommunityPersonBanView::get(pool, person_id, community_id)
|
||||
.await
|
||||
|
@ -212,7 +212,7 @@ pub async fn check_community_ban(
|
|||
#[tracing::instrument(skip_all)]
|
||||
pub async fn check_community_deleted_or_removed(
|
||||
community_id: CommunityId,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
) -> Result<(), LemmyError> {
|
||||
let community = Community::read(pool, community_id)
|
||||
.await
|
||||
|
@ -236,7 +236,7 @@ pub fn check_post_deleted_or_removed(post: &Post) -> Result<(), LemmyError> {
|
|||
pub async fn check_person_block(
|
||||
my_id: PersonId,
|
||||
potential_blocker_id: PersonId,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
) -> Result<(), LemmyError> {
|
||||
let is_blocked = PersonBlock::read(pool, potential_blocker_id, my_id)
|
||||
.await
|
||||
|
@ -270,7 +270,7 @@ pub fn check_private_instance(
|
|||
#[tracing::instrument(skip_all)]
|
||||
pub async fn build_federated_instances(
|
||||
local_site: &LocalSite,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
) -> Result<Option<FederatedInstances>, LemmyError> {
|
||||
if local_site.federation_enabled {
|
||||
// TODO I hate that this requires 3 queries
|
||||
|
@ -334,7 +334,7 @@ pub fn send_email_to_user(
|
|||
|
||||
pub async fn send_password_reset_email(
|
||||
user: &LocalUserView,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
settings: &Settings,
|
||||
) -> Result<(), LemmyError> {
|
||||
// Generate a random token
|
||||
|
@ -358,7 +358,7 @@ pub async fn send_password_reset_email(
|
|||
pub async fn send_verification_email(
|
||||
user: &LocalUserView,
|
||||
new_email: &str,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
settings: &Settings,
|
||||
) -> Result<(), LemmyError> {
|
||||
let form = EmailVerificationForm {
|
||||
|
@ -449,7 +449,7 @@ pub fn send_application_approved_email(
|
|||
/// Send a new applicant email notification to all admins
|
||||
pub async fn send_new_applicant_email_to_admins(
|
||||
applicant_username: &str,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
settings: &Settings,
|
||||
) -> Result<(), LemmyError> {
|
||||
// Collect the admins with emails
|
||||
|
@ -474,7 +474,7 @@ pub async fn send_new_applicant_email_to_admins(
|
|||
pub async fn send_new_report_email_to_admins(
|
||||
reporter_username: &str,
|
||||
reported_username: &str,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
settings: &Settings,
|
||||
) -> Result<(), LemmyError> {
|
||||
// Collect the admins with emails
|
||||
|
@ -495,7 +495,7 @@ pub async fn send_new_report_email_to_admins(
|
|||
pub async fn check_registration_application(
|
||||
local_user_view: &LocalUserView,
|
||||
local_site: &LocalSite,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
) -> Result<(), LemmyError> {
|
||||
if (local_site.registration_mode == RegistrationMode::RequireApplication
|
||||
|| local_site.registration_mode == RegistrationMode::Closed)
|
||||
|
@ -529,7 +529,7 @@ pub fn check_private_instance_and_federation_enabled(
|
|||
|
||||
pub async fn purge_image_posts_for_person(
|
||||
banned_person_id: PersonId,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
settings: &Settings,
|
||||
client: &ClientWithMiddleware,
|
||||
) -> Result<(), LemmyError> {
|
||||
|
@ -552,7 +552,7 @@ pub async fn purge_image_posts_for_person(
|
|||
|
||||
pub async fn purge_image_posts_for_community(
|
||||
banned_community_id: CommunityId,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
settings: &Settings,
|
||||
client: &ClientWithMiddleware,
|
||||
) -> Result<(), LemmyError> {
|
||||
|
@ -575,7 +575,7 @@ pub async fn purge_image_posts_for_community(
|
|||
|
||||
pub async fn remove_user_data(
|
||||
banned_person_id: PersonId,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
settings: &Settings,
|
||||
client: &ClientWithMiddleware,
|
||||
) -> Result<(), LemmyError> {
|
||||
|
@ -659,7 +659,7 @@ pub async fn remove_user_data(
|
|||
pub async fn remove_user_data_in_community(
|
||||
community_id: CommunityId,
|
||||
banned_person_id: PersonId,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
) -> Result<(), LemmyError> {
|
||||
// Posts
|
||||
Post::update_removed_for_creator(pool, banned_person_id, Some(community_id), true).await?;
|
||||
|
@ -689,7 +689,7 @@ pub async fn remove_user_data_in_community(
|
|||
|
||||
pub async fn delete_user_account(
|
||||
person_id: PersonId,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
settings: &Settings,
|
||||
client: &ClientWithMiddleware,
|
||||
) -> Result<(), LemmyError> {
|
||||
|
|
|
@ -21,7 +21,7 @@ use lemmy_api_common::{
|
|||
use lemmy_db_schema::{
|
||||
source::{community::Community, person::Person, site::Site},
|
||||
traits::Crud,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::DbPool,
|
||||
};
|
||||
use lemmy_db_views::structs::SiteView;
|
||||
use lemmy_utils::{error::LemmyError, utils::time::naive_from_unix};
|
||||
|
@ -118,10 +118,7 @@ impl SiteOrCommunity {
|
|||
}
|
||||
}
|
||||
|
||||
async fn generate_cc(
|
||||
target: &SiteOrCommunity,
|
||||
mut pool: &mut impl GetConn,
|
||||
) -> Result<Vec<Url>, LemmyError> {
|
||||
async fn generate_cc(target: &SiteOrCommunity, pool: &DbPool) -> Result<Vec<Url>, LemmyError> {
|
||||
Ok(match target {
|
||||
SiteOrCommunity::Site(_) => Site::read_remote_sites(pool)
|
||||
.await?
|
||||
|
|
|
@ -33,7 +33,7 @@ pub async fn resolve_object(
|
|||
async fn convert_response(
|
||||
object: SearchableObjects,
|
||||
user_id: PersonId,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
) -> Result<Json<ResolveObjectResponse>, LemmyError> {
|
||||
use SearchableObjects::*;
|
||||
let removed_or_deleted;
|
||||
|
|
|
@ -9,7 +9,7 @@ use lemmy_db_schema::{
|
|||
local_site::LocalSite,
|
||||
},
|
||||
traits::Crud,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::DbPool,
|
||||
};
|
||||
use lemmy_utils::{error::LemmyError, settings::structs::Settings};
|
||||
use once_cell::sync::Lazy;
|
||||
|
@ -98,7 +98,7 @@ pub(crate) struct LocalSiteData {
|
|||
}
|
||||
|
||||
pub(crate) async fn fetch_local_site_data(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
) -> Result<LocalSiteData, diesel::result::Error> {
|
||||
// LocalSite may be missing
|
||||
let local_site = LocalSite::read(pool).await.ok();
|
||||
|
|
|
@ -9,7 +9,7 @@ use lemmy_api_common::context::LemmyContext;
|
|||
use lemmy_db_schema::{
|
||||
source::{comment::Comment, person::Person, post::Post},
|
||||
traits::Crud,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::DbPool,
|
||||
};
|
||||
use lemmy_utils::{error::LemmyError, utils::mention::scrape_text_for_mentions};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -92,7 +92,7 @@ pub async fn collect_non_local_mentions(
|
|||
/// top-level comment, the creator of the post, otherwise the creator of the parent comment.
|
||||
#[tracing::instrument(skip(pool, comment))]
|
||||
async fn get_comment_parent_creator(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
comment: &Comment,
|
||||
) -> Result<ApubPerson, LemmyError> {
|
||||
let parent_creator_id = if let Some(parent_comment_id) = comment.parent_comment_id() {
|
||||
|
|
|
@ -195,9 +195,7 @@ pub(in crate::objects) async fn fetch_instance_actor_for_object<T: Into<Url> + C
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn remote_instance_inboxes(
|
||||
mut pool: &mut impl GetConn,
|
||||
) -> Result<Vec<Url>, LemmyError> {
|
||||
pub(crate) async fn remote_instance_inboxes(pool: &DbPool) -> Result<Vec<Url>, LemmyError> {
|
||||
Ok(
|
||||
Site::read_remote_sites(pool)
|
||||
.await?
|
||||
|
|
|
@ -2,7 +2,7 @@ use lemmy_db_schema::{
|
|||
impls::actor_language::UNDETERMINED_ID,
|
||||
newtypes::LanguageId,
|
||||
source::language::Language,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::DbPool,
|
||||
};
|
||||
use lemmy_utils::error::LemmyError;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -33,7 +33,7 @@ pub(crate) struct LanguageTag {
|
|||
impl LanguageTag {
|
||||
pub(crate) async fn new_single(
|
||||
lang: LanguageId,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
) -> Result<Option<LanguageTag>, LemmyError> {
|
||||
let lang = Language::read_from_id(pool, lang).await?;
|
||||
|
||||
|
@ -50,7 +50,7 @@ impl LanguageTag {
|
|||
|
||||
pub(crate) async fn new_multiple(
|
||||
lang_ids: Vec<LanguageId>,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
) -> Result<Vec<LanguageTag>, LemmyError> {
|
||||
let mut langs = Vec::<Language>::new();
|
||||
|
||||
|
@ -70,7 +70,7 @@ impl LanguageTag {
|
|||
|
||||
pub(crate) async fn to_language_id_single(
|
||||
lang: Option<Self>,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
) -> Result<Option<LanguageId>, LemmyError> {
|
||||
let identifier = lang.map(|l| l.identifier);
|
||||
let language = Language::read_id_from_code(pool, identifier.as_deref()).await?;
|
||||
|
@ -80,7 +80,7 @@ impl LanguageTag {
|
|||
|
||||
pub(crate) async fn to_language_id_multiple(
|
||||
langs: Vec<Self>,
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
) -> Result<Vec<LanguageId>, LemmyError> {
|
||||
let mut language_ids = Vec::new();
|
||||
|
||||
|
|
|
@ -2,25 +2,22 @@ use crate::{
|
|||
aggregates::structs::CommentAggregates,
|
||||
newtypes::CommentId,
|
||||
schema::comment_aggregates,
|
||||
utils::{functions::hot_rank, DbPool, GetConn},
|
||||
utils::{functions::hot_rank, get_conn, DbPool},
|
||||
};
|
||||
use diesel::{result::Error, ExpressionMethods, QueryDsl};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
||||
impl CommentAggregates {
|
||||
pub async fn read(mut pool: &mut impl GetConn, comment_id: CommentId) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read(pool: &DbPool, comment_id: CommentId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
comment_aggregates::table
|
||||
.filter(comment_aggregates::comment_id.eq(comment_id))
|
||||
.first::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn update_hot_rank(
|
||||
mut pool: &mut impl GetConn,
|
||||
comment_id: CommentId,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn update_hot_rank(pool: &DbPool, comment_id: CommentId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
diesel::update(comment_aggregates::table)
|
||||
.filter(comment_aggregates::comment_id.eq(comment_id))
|
||||
|
|
|
@ -2,14 +2,14 @@ use crate::{
|
|||
aggregates::structs::CommunityAggregates,
|
||||
newtypes::CommunityId,
|
||||
schema::community_aggregates,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{result::Error, ExpressionMethods, QueryDsl};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
||||
impl CommunityAggregates {
|
||||
pub async fn read(mut pool: &mut impl GetConn, community_id: CommunityId) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read(pool: &DbPool, community_id: CommunityId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
community_aggregates::table
|
||||
.filter(community_aggregates::community_id.eq(community_id))
|
||||
.first::<Self>(conn)
|
||||
|
|
|
@ -2,14 +2,14 @@ use crate::{
|
|||
aggregates::structs::PersonAggregates,
|
||||
newtypes::PersonId,
|
||||
schema::person_aggregates,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{result::Error, ExpressionMethods, QueryDsl};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
||||
impl PersonAggregates {
|
||||
pub async fn read(mut pool: &mut impl GetConn, person_id: PersonId) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read(pool: &DbPool, person_id: PersonId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
person_aggregates::table
|
||||
.filter(person_aggregates::person_id.eq(person_id))
|
||||
.first::<Self>(conn)
|
||||
|
|
|
@ -3,17 +3,14 @@ use crate::{
|
|||
diesel::BoolExpressionMethods,
|
||||
newtypes::{PersonId, PostId},
|
||||
schema::person_post_aggregates::dsl::{person_id, person_post_aggregates, post_id},
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{insert_into, result::Error, ExpressionMethods, QueryDsl};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
||||
impl PersonPostAggregates {
|
||||
pub async fn upsert(
|
||||
mut pool: &mut impl GetConn,
|
||||
form: &PersonPostAggregatesForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn upsert(pool: &DbPool, form: &PersonPostAggregatesForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(person_post_aggregates)
|
||||
.values(form)
|
||||
.on_conflict((person_id, post_id))
|
||||
|
@ -22,12 +19,8 @@ impl PersonPostAggregates {
|
|||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
pub async fn read(
|
||||
mut pool: &mut impl GetConn,
|
||||
person_id_: PersonId,
|
||||
post_id_: PostId,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read(pool: &DbPool, person_id_: PersonId, post_id_: PostId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
person_post_aggregates
|
||||
.filter(post_id.eq(post_id_).and(person_id.eq(person_id_)))
|
||||
.first::<Self>(conn)
|
||||
|
|
|
@ -2,25 +2,22 @@ use crate::{
|
|||
aggregates::structs::PostAggregates,
|
||||
newtypes::PostId,
|
||||
schema::post_aggregates,
|
||||
utils::{functions::hot_rank, DbPool, GetConn},
|
||||
utils::{functions::hot_rank, get_conn, DbPool},
|
||||
};
|
||||
use diesel::{result::Error, ExpressionMethods, QueryDsl};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
||||
impl PostAggregates {
|
||||
pub async fn read(mut pool: &mut impl GetConn, post_id: PostId) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read(pool: &DbPool, post_id: PostId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
post_aggregates::table
|
||||
.filter(post_aggregates::post_id.eq(post_id))
|
||||
.first::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn update_hot_rank(
|
||||
mut pool: &mut impl GetConn,
|
||||
post_id: PostId,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn update_hot_rank(pool: &DbPool, post_id: PostId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
diesel::update(post_aggregates::table)
|
||||
.filter(post_aggregates::post_id.eq(post_id))
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use crate::{
|
||||
aggregates::structs::SiteAggregates,
|
||||
schema::site_aggregates,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::result::Error;
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
||||
impl SiteAggregates {
|
||||
pub async fn read(mut pool: &mut impl GetConn) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read(pool: &DbPool) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
site_aggregates::table.first::<Self>(conn).await
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::{
|
|||
schema::activity::dsl::{activity, ap_id},
|
||||
source::activity::{Activity, ActivityInsertForm, ActivityUpdateForm},
|
||||
traits::Crud,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
@ -13,16 +13,13 @@ impl Crud for Activity {
|
|||
type InsertForm = ActivityInsertForm;
|
||||
type UpdateForm = ActivityUpdateForm;
|
||||
type IdType = i32;
|
||||
async fn read(mut pool: &mut impl GetConn, activity_id: i32) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn read(pool: &DbPool, activity_id: i32) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
activity.find(activity_id).first::<Self>(conn).await
|
||||
}
|
||||
|
||||
async fn create(
|
||||
mut pool: &mut impl GetConn,
|
||||
new_activity: &Self::InsertForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn create(pool: &DbPool, new_activity: &Self::InsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(activity)
|
||||
.values(new_activity)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -30,18 +27,18 @@ impl Crud for Activity {
|
|||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
activity_id: i32,
|
||||
new_activity: &Self::UpdateForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(activity.find(activity_id))
|
||||
.set(new_activity)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
async fn delete(mut pool: &mut impl GetConn, activity_id: i32) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn delete(pool: &DbPool, activity_id: i32) -> Result<usize, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(activity.find(activity_id))
|
||||
.execute(conn)
|
||||
.await
|
||||
|
@ -49,11 +46,8 @@ impl Crud for Activity {
|
|||
}
|
||||
|
||||
impl Activity {
|
||||
pub async fn read_from_apub_id(
|
||||
mut pool: &mut impl GetConn,
|
||||
object_id: &DbUrl,
|
||||
) -> Result<Activity, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read_from_apub_id(pool: &DbPool, object_id: &DbUrl) -> Result<Activity, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
activity
|
||||
.filter(ap_id.eq(object_id))
|
||||
.first::<Self>(conn)
|
||||
|
|
|
@ -14,7 +14,7 @@ use crate::{
|
|||
language::Language,
|
||||
site::Site,
|
||||
},
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{
|
||||
delete,
|
||||
|
@ -37,7 +37,7 @@ pub const UNDETERMINED_ID: LanguageId = LanguageId(0);
|
|||
|
||||
impl LocalUserLanguage {
|
||||
pub async fn read(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_local_user_id: LocalUserId,
|
||||
) -> Result<Vec<LanguageId>, Error> {
|
||||
use crate::schema::local_user_language::dsl::{
|
||||
|
@ -45,7 +45,7 @@ impl LocalUserLanguage {
|
|||
local_user_id,
|
||||
local_user_language,
|
||||
};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
conn
|
||||
.build_transaction()
|
||||
|
@ -67,15 +67,15 @@ impl LocalUserLanguage {
|
|||
///
|
||||
/// If no language_id vector is given, it will show all languages
|
||||
pub async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
language_ids: Vec<LanguageId>,
|
||||
for_local_user_id: LocalUserId,
|
||||
) -> Result<(), Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let mut lang_ids = convert_update_languages(conn, language_ids).await?;
|
||||
|
||||
// No need to update if languages are unchanged
|
||||
let current = LocalUserLanguage::read(conn, for_local_user_id).await?;
|
||||
let current = LocalUserLanguage::read(pool, for_local_user_id).await?;
|
||||
if current == lang_ids {
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -118,8 +118,8 @@ impl LocalUserLanguage {
|
|||
}
|
||||
|
||||
impl SiteLanguage {
|
||||
pub async fn read_local_raw(mut pool: &mut impl GetConn) -> Result<Vec<LanguageId>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read_local_raw(pool: &DbPool) -> Result<Vec<LanguageId>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
site::table
|
||||
.inner_join(local_site::table)
|
||||
.inner_join(site_language::table)
|
||||
|
@ -130,7 +130,7 @@ impl SiteLanguage {
|
|||
}
|
||||
|
||||
async fn read_raw(
|
||||
conn: &mut AsyncPgConnection,
|
||||
conn: &mut PooledConnection<AsyncPgConnection>,
|
||||
for_site_id: SiteId,
|
||||
) -> Result<Vec<LanguageId>, Error> {
|
||||
site_language::table
|
||||
|
@ -141,28 +141,25 @@ impl SiteLanguage {
|
|||
.await
|
||||
}
|
||||
|
||||
pub async fn read(
|
||||
mut pool: &mut impl GetConn,
|
||||
for_site_id: SiteId,
|
||||
) -> Result<Vec<LanguageId>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read(pool: &DbPool, for_site_id: SiteId) -> Result<Vec<LanguageId>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let langs = Self::read_raw(conn, for_site_id).await?;
|
||||
|
||||
convert_read_languages(conn, langs).await
|
||||
}
|
||||
|
||||
pub async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
language_ids: Vec<LanguageId>,
|
||||
site: &Site,
|
||||
) -> Result<(), Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let for_site_id = site.id;
|
||||
let instance_id = site.instance_id;
|
||||
let lang_ids = convert_update_languages(conn, language_ids).await?;
|
||||
|
||||
// No need to update if languages are unchanged
|
||||
let current = SiteLanguage::read(conn, site.id).await?;
|
||||
let current = SiteLanguage::read(pool, site.id).await?;
|
||||
if current == lang_ids {
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -201,12 +198,12 @@ impl SiteLanguage {
|
|||
impl CommunityLanguage {
|
||||
/// Returns true if the given language is one of configured languages for given community
|
||||
pub async fn is_allowed_community_language(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_language_id: Option<LanguageId>,
|
||||
for_community_id: CommunityId,
|
||||
) -> Result<(), LemmyError> {
|
||||
use crate::schema::community_language::dsl::{community_id, community_language, language_id};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
if let Some(for_language_id) = for_language_id {
|
||||
let is_allowed = select(exists(
|
||||
|
@ -258,7 +255,7 @@ impl CommunityLanguage {
|
|||
}
|
||||
|
||||
async fn read_raw(
|
||||
conn: &mut AsyncPgConnection,
|
||||
conn: &mut PooledConnection<AsyncPgConnection>,
|
||||
for_community_id: CommunityId,
|
||||
) -> Result<Vec<LanguageId>, Error> {
|
||||
use crate::schema::community_language::dsl::{community_id, community_language, language_id};
|
||||
|
@ -271,22 +268,22 @@ impl CommunityLanguage {
|
|||
}
|
||||
|
||||
pub async fn read(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_community_id: CommunityId,
|
||||
) -> Result<Vec<LanguageId>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let langs = Self::read_raw(conn, for_community_id).await?;
|
||||
convert_read_languages(conn, langs).await
|
||||
}
|
||||
|
||||
pub async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
mut language_ids: Vec<LanguageId>,
|
||||
for_community_id: CommunityId,
|
||||
) -> Result<(), Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
if language_ids.is_empty() {
|
||||
language_ids = SiteLanguage::read_local_raw(conn).await?;
|
||||
language_ids = SiteLanguage::read_local_raw(pool).await?;
|
||||
}
|
||||
let lang_ids = convert_update_languages(conn, language_ids).await?;
|
||||
|
||||
|
@ -324,12 +321,12 @@ impl CommunityLanguage {
|
|||
}
|
||||
|
||||
pub async fn default_post_language(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
community_id: CommunityId,
|
||||
local_user_id: LocalUserId,
|
||||
) -> Result<Option<LanguageId>, Error> {
|
||||
use crate::schema::{community_language::dsl as cl, local_user_language::dsl as ul};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let mut intersection = ul::local_user_language
|
||||
.inner_join(cl::community_language.on(ul::language_id.eq(cl::language_id)))
|
||||
.filter(ul::local_user_id.eq(local_user_id))
|
||||
|
@ -399,9 +396,9 @@ mod tests {
|
|||
convert_read_languages,
|
||||
convert_update_languages,
|
||||
default_post_language,
|
||||
get_conn,
|
||||
CommunityLanguage,
|
||||
DbPool,
|
||||
GetConn,
|
||||
Language,
|
||||
LanguageId,
|
||||
LocalUserLanguage,
|
||||
|
@ -422,7 +419,7 @@ mod tests {
|
|||
};
|
||||
use serial_test::serial;
|
||||
|
||||
async fn test_langs1(mut pool: &mut impl GetConn) -> Vec<LanguageId> {
|
||||
async fn test_langs1(pool: &DbPool) -> Vec<LanguageId> {
|
||||
vec![
|
||||
Language::read_id_from_code(pool, Some("en"))
|
||||
.await
|
||||
|
@ -438,7 +435,7 @@ mod tests {
|
|||
.unwrap(),
|
||||
]
|
||||
}
|
||||
async fn test_langs2(mut pool: &mut impl GetConn) -> Vec<LanguageId> {
|
||||
async fn test_langs2(pool: &DbPool) -> Vec<LanguageId> {
|
||||
vec![
|
||||
Language::read_id_from_code(pool, Some("fi"))
|
||||
.await
|
||||
|
@ -451,7 +448,7 @@ mod tests {
|
|||
]
|
||||
}
|
||||
|
||||
async fn create_test_site(mut pool: &mut impl GetConn) -> (Site, Instance) {
|
||||
async fn create_test_site(pool: &DbPool) -> (Site, Instance) {
|
||||
let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string())
|
||||
.await
|
||||
.unwrap();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{
|
||||
schema::captcha_answer::dsl::{answer, captcha_answer, uuid},
|
||||
source::captcha_answer::{CaptchaAnswer, CaptchaAnswerForm, CheckCaptchaAnswer},
|
||||
utils::{functions::lower, DbPool, GetConn},
|
||||
utils::{functions::lower, get_conn, DbPool},
|
||||
};
|
||||
use diesel::{
|
||||
delete,
|
||||
|
@ -15,11 +15,8 @@ use diesel::{
|
|||
use diesel_async::RunQueryDsl;
|
||||
|
||||
impl CaptchaAnswer {
|
||||
pub async fn insert(
|
||||
mut pool: &mut impl GetConn,
|
||||
captcha: &CaptchaAnswerForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn insert(pool: &DbPool, captcha: &CaptchaAnswerForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
insert_into(captcha_answer)
|
||||
.values(captcha)
|
||||
|
@ -27,11 +24,8 @@ impl CaptchaAnswer {
|
|||
.await
|
||||
}
|
||||
|
||||
pub async fn check_captcha(
|
||||
mut pool: &mut impl GetConn,
|
||||
to_check: CheckCaptchaAnswer,
|
||||
) -> Result<bool, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn check_captcha(pool: &DbPool, to_check: CheckCaptchaAnswer) -> Result<bool, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
// fetch requested captcha
|
||||
let captcha_exists = select(exists(
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::{
|
|||
CommentUpdateForm,
|
||||
},
|
||||
traits::{Crud, Likeable, Saveable},
|
||||
utils::{naive_now, DbPool, GetConn, DELETED_REPLACEMENT_TEXT},
|
||||
utils::{get_conn, naive_now, DbPool, DELETED_REPLACEMENT_TEXT},
|
||||
};
|
||||
use diesel::{
|
||||
dsl::{insert_into, sql_query},
|
||||
|
@ -25,10 +25,10 @@ use url::Url;
|
|||
|
||||
impl Comment {
|
||||
pub async fn permadelete_for_creator(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_creator_id: PersonId,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
diesel::update(comment.filter(creator_id.eq(for_creator_id)))
|
||||
.set((
|
||||
|
@ -41,11 +41,11 @@ impl Comment {
|
|||
}
|
||||
|
||||
pub async fn update_removed_for_creator(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_creator_id: PersonId,
|
||||
new_removed: bool,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(comment.filter(creator_id.eq(for_creator_id)))
|
||||
.set((removed.eq(new_removed), updated.eq(naive_now())))
|
||||
.get_results::<Self>(conn)
|
||||
|
@ -53,11 +53,11 @@ impl Comment {
|
|||
}
|
||||
|
||||
pub async fn create(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
comment_form: &CommentInsertForm,
|
||||
parent_path: Option<&Ltree>,
|
||||
) -> Result<Comment, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
// Insert, to get the id
|
||||
let inserted_comment = insert_into(comment)
|
||||
|
@ -123,11 +123,8 @@ where ca.comment_id = c.id"
|
|||
inserted_comment
|
||||
}
|
||||
}
|
||||
pub async fn read_from_apub_id(
|
||||
mut pool: &mut impl GetConn,
|
||||
object_id: Url,
|
||||
) -> Result<Option<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read_from_apub_id(pool: &DbPool, object_id: Url) -> Result<Option<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let object_id: DbUrl = object_id.into();
|
||||
Ok(
|
||||
comment
|
||||
|
@ -156,30 +153,27 @@ impl Crud for Comment {
|
|||
type InsertForm = CommentInsertForm;
|
||||
type UpdateForm = CommentUpdateForm;
|
||||
type IdType = CommentId;
|
||||
async fn read(mut pool: &mut impl GetConn, comment_id: CommentId) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn read(pool: &DbPool, comment_id: CommentId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
comment.find(comment_id).first::<Self>(conn).await
|
||||
}
|
||||
|
||||
async fn delete(mut pool: &mut impl GetConn, comment_id: CommentId) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn delete(pool: &DbPool, comment_id: CommentId) -> Result<usize, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(comment.find(comment_id)).execute(conn).await
|
||||
}
|
||||
|
||||
/// This is unimplemented, use [[Comment::create]]
|
||||
async fn create(
|
||||
_pool: &mut impl GetConn,
|
||||
_comment_form: &Self::InsertForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn create(_pool: &DbPool, _comment_form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
comment_id: CommentId,
|
||||
comment_form: &Self::UpdateForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(comment.find(comment_id))
|
||||
.set(comment_form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -191,12 +185,9 @@ impl Crud for Comment {
|
|||
impl Likeable for CommentLike {
|
||||
type Form = CommentLikeForm;
|
||||
type IdType = CommentId;
|
||||
async fn like(
|
||||
mut pool: &mut impl GetConn,
|
||||
comment_like_form: &CommentLikeForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn like(pool: &DbPool, comment_like_form: &CommentLikeForm) -> Result<Self, Error> {
|
||||
use crate::schema::comment_like::dsl::{comment_id, comment_like, person_id};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(comment_like)
|
||||
.values(comment_like_form)
|
||||
.on_conflict((comment_id, person_id))
|
||||
|
@ -206,12 +197,12 @@ impl Likeable for CommentLike {
|
|||
.await
|
||||
}
|
||||
async fn remove(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
person_id_: PersonId,
|
||||
comment_id_: CommentId,
|
||||
) -> Result<usize, Error> {
|
||||
use crate::schema::comment_like::dsl::{comment_id, comment_like, person_id};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(
|
||||
comment_like
|
||||
.filter(comment_id.eq(comment_id_))
|
||||
|
@ -225,12 +216,9 @@ impl Likeable for CommentLike {
|
|||
#[async_trait]
|
||||
impl Saveable for CommentSaved {
|
||||
type Form = CommentSavedForm;
|
||||
async fn save(
|
||||
mut pool: &mut impl GetConn,
|
||||
comment_saved_form: &CommentSavedForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn save(pool: &DbPool, comment_saved_form: &CommentSavedForm) -> Result<Self, Error> {
|
||||
use crate::schema::comment_saved::dsl::{comment_id, comment_saved, person_id};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(comment_saved)
|
||||
.values(comment_saved_form)
|
||||
.on_conflict((comment_id, person_id))
|
||||
|
@ -239,12 +227,9 @@ impl Saveable for CommentSaved {
|
|||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
async fn unsave(
|
||||
mut pool: &mut impl GetConn,
|
||||
comment_saved_form: &CommentSavedForm,
|
||||
) -> Result<usize, Error> {
|
||||
async fn unsave(pool: &DbPool, comment_saved_form: &CommentSavedForm) -> Result<usize, Error> {
|
||||
use crate::schema::comment_saved::dsl::{comment_id, comment_saved, person_id};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(
|
||||
comment_saved
|
||||
.filter(comment_id.eq(comment_saved_form.comment_id))
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::{
|
|||
schema::comment_reply::dsl::{comment_id, comment_reply, read, recipient_id},
|
||||
source::comment_reply::{CommentReply, CommentReplyInsertForm, CommentReplyUpdateForm},
|
||||
traits::Crud,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
@ -13,22 +13,16 @@ impl Crud for CommentReply {
|
|||
type InsertForm = CommentReplyInsertForm;
|
||||
type UpdateForm = CommentReplyUpdateForm;
|
||||
type IdType = CommentReplyId;
|
||||
async fn read(
|
||||
mut pool: &mut impl GetConn,
|
||||
comment_reply_id: CommentReplyId,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn read(pool: &DbPool, comment_reply_id: CommentReplyId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
comment_reply
|
||||
.find(comment_reply_id)
|
||||
.first::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn create(
|
||||
mut pool: &mut impl GetConn,
|
||||
comment_reply_form: &Self::InsertForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn create(pool: &DbPool, comment_reply_form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
// since the return here isnt utilized, we dont need to do an update
|
||||
// but get_result doesnt return the existing row here
|
||||
|
@ -42,11 +36,11 @@ impl Crud for CommentReply {
|
|||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
comment_reply_id: CommentReplyId,
|
||||
comment_reply_form: &Self::UpdateForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(comment_reply.find(comment_reply_id))
|
||||
.set(comment_reply_form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -56,10 +50,10 @@ impl Crud for CommentReply {
|
|||
|
||||
impl CommentReply {
|
||||
pub async fn mark_all_as_read(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_recipient_id: PersonId,
|
||||
) -> Result<Vec<CommentReply>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(
|
||||
comment_reply
|
||||
.filter(recipient_id.eq(for_recipient_id))
|
||||
|
@ -70,11 +64,8 @@ impl CommentReply {
|
|||
.await
|
||||
}
|
||||
|
||||
pub async fn read_by_comment(
|
||||
mut pool: &mut impl GetConn,
|
||||
for_comment_id: CommentId,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read_by_comment(pool: &DbPool, for_comment_id: CommentId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
comment_reply
|
||||
.filter(comment_id.eq(for_comment_id))
|
||||
.first::<Self>(conn)
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::{
|
|||
schema::comment_report::dsl::{comment_report, resolved, resolver_id, updated},
|
||||
source::comment_report::{CommentReport, CommentReportForm},
|
||||
traits::Reportable,
|
||||
utils::{naive_now, DbPool, GetConn},
|
||||
utils::{get_conn, naive_now, DbPool},
|
||||
};
|
||||
use diesel::{
|
||||
dsl::{insert_into, update},
|
||||
|
@ -21,11 +21,8 @@ impl Reportable for CommentReport {
|
|||
///
|
||||
/// * `conn` - the postgres connection
|
||||
/// * `comment_report_form` - the filled CommentReportForm to insert
|
||||
async fn report(
|
||||
mut pool: &mut impl GetConn,
|
||||
comment_report_form: &CommentReportForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn report(pool: &DbPool, comment_report_form: &CommentReportForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(comment_report)
|
||||
.values(comment_report_form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -38,11 +35,11 @@ impl Reportable for CommentReport {
|
|||
/// * `report_id` - the id of the report to resolve
|
||||
/// * `by_resolver_id` - the id of the user resolving the report
|
||||
async fn resolve(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
report_id_: Self::IdType,
|
||||
by_resolver_id: PersonId,
|
||||
) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
update(comment_report.find(report_id_))
|
||||
.set((
|
||||
resolved.eq(true),
|
||||
|
@ -59,11 +56,11 @@ impl Reportable for CommentReport {
|
|||
/// * `report_id` - the id of the report to unresolve
|
||||
/// * `by_resolver_id` - the id of the user unresolving the report
|
||||
async fn unresolve(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
report_id_: Self::IdType,
|
||||
by_resolver_id: PersonId,
|
||||
) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
update(comment_report.find(report_id_))
|
||||
.set((
|
||||
resolved.eq(false),
|
||||
|
|
|
@ -16,7 +16,7 @@ use crate::{
|
|||
},
|
||||
},
|
||||
traits::{ApubActor, Bannable, Crud, Followable, Joinable},
|
||||
utils::{functions::lower, DbPool, GetConn},
|
||||
utils::{functions::lower, get_conn, DbPool},
|
||||
SubscribedType,
|
||||
};
|
||||
use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl};
|
||||
|
@ -27,23 +27,23 @@ impl Crud for Community {
|
|||
type InsertForm = CommunityInsertForm;
|
||||
type UpdateForm = CommunityUpdateForm;
|
||||
type IdType = CommunityId;
|
||||
async fn read(mut pool: &mut impl GetConn, community_id: CommunityId) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn read(pool: &DbPool, community_id: CommunityId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
community::table
|
||||
.find(community_id)
|
||||
.first::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn delete(mut pool: &mut impl GetConn, community_id: CommunityId) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn delete(pool: &DbPool, community_id: CommunityId) -> Result<usize, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(community::table.find(community_id))
|
||||
.execute(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn create(mut pool: &mut impl GetConn, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn create(pool: &DbPool, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let is_new_community = match &form.actor_id {
|
||||
Some(id) => Community::read_from_apub_id(pool, id).await?.is_none(),
|
||||
None => true,
|
||||
|
@ -67,11 +67,11 @@ impl Crud for Community {
|
|||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
community_id: CommunityId,
|
||||
form: &Self::UpdateForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(community::table.find(community_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -83,11 +83,11 @@ impl Crud for Community {
|
|||
impl Joinable for CommunityModerator {
|
||||
type Form = CommunityModeratorForm;
|
||||
async fn join(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
community_moderator_form: &CommunityModeratorForm,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::community_moderator::dsl::community_moderator;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(community_moderator)
|
||||
.values(community_moderator_form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -95,11 +95,11 @@ impl Joinable for CommunityModerator {
|
|||
}
|
||||
|
||||
async fn leave(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
community_moderator_form: &CommunityModeratorForm,
|
||||
) -> Result<usize, Error> {
|
||||
use crate::schema::community_moderator::dsl::{community_id, community_moderator, person_id};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(
|
||||
community_moderator
|
||||
.filter(community_id.eq(community_moderator_form.community_id))
|
||||
|
@ -118,12 +118,12 @@ pub enum CollectionType {
|
|||
impl Community {
|
||||
/// Get the community which has a given moderators or featured url, also return the collection type
|
||||
pub async fn get_by_collection_url(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
url: &DbUrl,
|
||||
) -> Result<(Community, CollectionType), Error> {
|
||||
use crate::schema::community::dsl::{featured_url, moderators_url};
|
||||
use CollectionType::*;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let res = community::table
|
||||
.filter(moderators_url.eq(url))
|
||||
.first::<Self>(conn)
|
||||
|
@ -144,11 +144,11 @@ impl Community {
|
|||
|
||||
impl CommunityModerator {
|
||||
pub async fn delete_for_community(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_community_id: CommunityId,
|
||||
) -> Result<usize, Error> {
|
||||
use crate::schema::community_moderator::dsl::{community_id, community_moderator};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
diesel::delete(community_moderator.filter(community_id.eq(for_community_id)))
|
||||
.execute(conn)
|
||||
|
@ -156,22 +156,22 @@ impl CommunityModerator {
|
|||
}
|
||||
|
||||
pub async fn leave_all_communities(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_person_id: PersonId,
|
||||
) -> Result<usize, Error> {
|
||||
use crate::schema::community_moderator::dsl::{community_moderator, person_id};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(community_moderator.filter(person_id.eq(for_person_id)))
|
||||
.execute(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_person_moderated_communities(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_person_id: PersonId,
|
||||
) -> Result<Vec<CommunityId>, Error> {
|
||||
use crate::schema::community_moderator::dsl::{community_id, community_moderator, person_id};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
community_moderator
|
||||
.filter(person_id.eq(for_person_id))
|
||||
.select(community_id)
|
||||
|
@ -184,11 +184,11 @@ impl CommunityModerator {
|
|||
impl Bannable for CommunityPersonBan {
|
||||
type Form = CommunityPersonBanForm;
|
||||
async fn ban(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
community_person_ban_form: &CommunityPersonBanForm,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::community_person_ban::dsl::{community_id, community_person_ban, person_id};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(community_person_ban)
|
||||
.values(community_person_ban_form)
|
||||
.on_conflict((community_id, person_id))
|
||||
|
@ -199,11 +199,11 @@ impl Bannable for CommunityPersonBan {
|
|||
}
|
||||
|
||||
async fn unban(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
community_person_ban_form: &CommunityPersonBanForm,
|
||||
) -> Result<usize, Error> {
|
||||
use crate::schema::community_person_ban::dsl::{community_id, community_person_ban, person_id};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(
|
||||
community_person_ban
|
||||
.filter(community_id.eq(community_person_ban_form.community_id))
|
||||
|
@ -233,12 +233,9 @@ impl CommunityFollower {
|
|||
#[async_trait]
|
||||
impl Followable for CommunityFollower {
|
||||
type Form = CommunityFollowerForm;
|
||||
async fn follow(
|
||||
mut pool: &mut impl GetConn,
|
||||
form: &CommunityFollowerForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn follow(pool: &DbPool, form: &CommunityFollowerForm) -> Result<Self, Error> {
|
||||
use crate::schema::community_follower::dsl::{community_follower, community_id, person_id};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(community_follower)
|
||||
.values(form)
|
||||
.on_conflict((community_id, person_id))
|
||||
|
@ -248,7 +245,7 @@ impl Followable for CommunityFollower {
|
|||
.await
|
||||
}
|
||||
async fn follow_accepted(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
community_id_: CommunityId,
|
||||
person_id_: PersonId,
|
||||
) -> Result<Self, Error> {
|
||||
|
@ -258,7 +255,7 @@ impl Followable for CommunityFollower {
|
|||
pending,
|
||||
person_id,
|
||||
};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(
|
||||
community_follower
|
||||
.filter(community_id.eq(community_id_))
|
||||
|
@ -268,12 +265,9 @@ impl Followable for CommunityFollower {
|
|||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
async fn unfollow(
|
||||
mut pool: &mut impl GetConn,
|
||||
form: &CommunityFollowerForm,
|
||||
) -> Result<usize, Error> {
|
||||
async fn unfollow(pool: &DbPool, form: &CommunityFollowerForm) -> Result<usize, Error> {
|
||||
use crate::schema::community_follower::dsl::{community_follower, community_id, person_id};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(
|
||||
community_follower
|
||||
.filter(community_id.eq(&form.community_id))
|
||||
|
@ -286,11 +280,8 @@ impl Followable for CommunityFollower {
|
|||
|
||||
#[async_trait]
|
||||
impl ApubActor for Community {
|
||||
async fn read_from_apub_id(
|
||||
mut pool: &mut impl GetConn,
|
||||
object_id: &DbUrl,
|
||||
) -> Result<Option<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn read_from_apub_id(pool: &DbPool, object_id: &DbUrl) -> Result<Option<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
Ok(
|
||||
community::table
|
||||
.filter(community::actor_id.eq(object_id))
|
||||
|
@ -302,11 +293,11 @@ impl ApubActor for Community {
|
|||
}
|
||||
|
||||
async fn read_from_name(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
community_name: &str,
|
||||
include_deleted: bool,
|
||||
) -> Result<Community, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let mut q = community::table
|
||||
.into_boxed()
|
||||
.filter(community::local.eq(true))
|
||||
|
@ -320,11 +311,11 @@ impl ApubActor for Community {
|
|||
}
|
||||
|
||||
async fn read_from_name_and_domain(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
community_name: &str,
|
||||
for_domain: &str,
|
||||
) -> Result<Community, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
community::table
|
||||
.inner_join(instance::table)
|
||||
.filter(lower(community::name).eq(community_name.to_lowercase()))
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::{
|
|||
schema::community_block::dsl::{community_block, community_id, person_id},
|
||||
source::community_block::{CommunityBlock, CommunityBlockForm},
|
||||
traits::Blockable,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
@ -10,11 +10,8 @@ use diesel_async::RunQueryDsl;
|
|||
#[async_trait]
|
||||
impl Blockable for CommunityBlock {
|
||||
type Form = CommunityBlockForm;
|
||||
async fn block(
|
||||
mut pool: &mut impl GetConn,
|
||||
community_block_form: &Self::Form,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn block(pool: &DbPool, community_block_form: &Self::Form) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(community_block)
|
||||
.values(community_block_form)
|
||||
.on_conflict((person_id, community_id))
|
||||
|
@ -23,11 +20,8 @@ impl Blockable for CommunityBlock {
|
|||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
async fn unblock(
|
||||
mut pool: &mut impl GetConn,
|
||||
community_block_form: &Self::Form,
|
||||
) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn unblock(pool: &DbPool, community_block_form: &Self::Form) -> Result<usize, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(
|
||||
community_block
|
||||
.filter(person_id.eq(community_block_form.person_id))
|
||||
|
|
|
@ -8,38 +8,32 @@ use crate::{
|
|||
custom_emoji::{CustomEmoji, CustomEmojiInsertForm, CustomEmojiUpdateForm},
|
||||
custom_emoji_keyword::{CustomEmojiKeyword, CustomEmojiKeywordInsertForm},
|
||||
},
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
||||
impl CustomEmoji {
|
||||
pub async fn create(
|
||||
mut pool: &mut impl GetConn,
|
||||
form: &CustomEmojiInsertForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn create(pool: &DbPool, form: &CustomEmojiInsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(custom_emoji)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
pub async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
emoji_id: CustomEmojiId,
|
||||
form: &CustomEmojiUpdateForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(custom_emoji.find(emoji_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
pub async fn delete(
|
||||
mut pool: &mut impl GetConn,
|
||||
emoji_id: CustomEmojiId,
|
||||
) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn delete(pool: &DbPool, emoji_id: CustomEmojiId) -> Result<usize, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(custom_emoji.find(emoji_id))
|
||||
.execute(conn)
|
||||
.await
|
||||
|
@ -48,20 +42,17 @@ impl CustomEmoji {
|
|||
|
||||
impl CustomEmojiKeyword {
|
||||
pub async fn create(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
form: Vec<CustomEmojiKeywordInsertForm>,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(custom_emoji_keyword)
|
||||
.values(form)
|
||||
.get_results::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
pub async fn delete(
|
||||
mut pool: &mut impl GetConn,
|
||||
emoji_id: CustomEmojiId,
|
||||
) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn delete(pool: &DbPool, emoji_id: CustomEmojiId) -> Result<usize, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(custom_emoji_keyword.filter(custom_emoji_id.eq(emoji_id)))
|
||||
.execute(conn)
|
||||
.await
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::{
|
|||
verification_token,
|
||||
},
|
||||
source::email_verification::{EmailVerification, EmailVerificationForm},
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{
|
||||
dsl::{now, IntervalDsl},
|
||||
|
@ -19,19 +19,16 @@ use diesel::{
|
|||
use diesel_async::RunQueryDsl;
|
||||
|
||||
impl EmailVerification {
|
||||
pub async fn create(
|
||||
mut pool: &mut impl GetConn,
|
||||
form: &EmailVerificationForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn create(pool: &DbPool, form: &EmailVerificationForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(email_verification)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn read_for_token(mut pool: &mut impl GetConn, token: &str) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read_for_token(pool: &DbPool, token: &str) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
email_verification
|
||||
.filter(verification_token.eq(token))
|
||||
.filter(published.gt(now - 7.days()))
|
||||
|
@ -39,10 +36,10 @@ impl EmailVerification {
|
|||
.await
|
||||
}
|
||||
pub async fn delete_old_tokens_for_local_user(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
local_user_id_: LocalUserId,
|
||||
) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(email_verification.filter(local_user_id.eq(local_user_id_)))
|
||||
.execute(conn)
|
||||
.await
|
||||
|
|
|
@ -4,17 +4,14 @@ use crate::{
|
|||
federation_allowlist::{FederationAllowList, FederationAllowListForm},
|
||||
instance::Instance,
|
||||
},
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{dsl::insert_into, result::Error};
|
||||
use diesel_async::{AsyncPgConnection, RunQueryDsl};
|
||||
|
||||
impl FederationAllowList {
|
||||
pub async fn replace(
|
||||
mut pool: &mut impl GetConn,
|
||||
list_opt: Option<Vec<String>>,
|
||||
) -> Result<(), Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn replace(pool: &DbPool, list_opt: Option<Vec<String>>) -> Result<(), Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
conn
|
||||
.build_transaction()
|
||||
.run(|conn| {
|
||||
|
|
|
@ -4,17 +4,14 @@ use crate::{
|
|||
federation_blocklist::{FederationBlockList, FederationBlockListForm},
|
||||
instance::Instance,
|
||||
},
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{dsl::insert_into, result::Error};
|
||||
use diesel_async::{AsyncPgConnection, RunQueryDsl};
|
||||
|
||||
impl FederationBlockList {
|
||||
pub async fn replace(
|
||||
mut pool: &mut impl GetConn,
|
||||
list_opt: Option<Vec<String>>,
|
||||
) -> Result<(), Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn replace(pool: &DbPool, list_opt: Option<Vec<String>>) -> Result<(), Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
conn
|
||||
.build_transaction()
|
||||
.run(|conn| {
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::{
|
|||
newtypes::InstanceId,
|
||||
schema::{federation_allowlist, federation_blocklist, instance},
|
||||
source::instance::{Instance, InstanceForm},
|
||||
utils::{naive_now, DbPool, GetConn},
|
||||
utils::{get_conn, naive_now, DbPool},
|
||||
};
|
||||
use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl};
|
||||
use diesel_async::{AsyncPgConnection, RunQueryDsl};
|
||||
|
@ -42,26 +42,23 @@ impl Instance {
|
|||
|
||||
/// Attempt to read Instance column for the given domain. If it doesnt exist, insert a new one.
|
||||
/// There is no need for update as the domain of an existing instance cant change.
|
||||
pub async fn read_or_create(mut pool: &mut impl GetConn, domain: String) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read_or_create(pool: &DbPool, domain: String) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
Self::read_or_create_with_conn(conn, domain).await
|
||||
}
|
||||
pub async fn delete(
|
||||
mut pool: &mut impl GetConn,
|
||||
instance_id: InstanceId,
|
||||
) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn delete(pool: &DbPool, instance_id: InstanceId) -> Result<usize, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(instance::table.find(instance_id))
|
||||
.execute(conn)
|
||||
.await
|
||||
}
|
||||
#[cfg(test)]
|
||||
pub async fn delete_all(mut pool: &mut impl GetConn) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn delete_all(pool: &DbPool) -> Result<usize, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(instance::table).execute(conn).await
|
||||
}
|
||||
pub async fn allowlist(mut pool: &mut impl GetConn) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn allowlist(pool: &DbPool) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
instance::table
|
||||
.inner_join(federation_allowlist::table)
|
||||
.select(instance::all_columns)
|
||||
|
@ -69,8 +66,8 @@ impl Instance {
|
|||
.await
|
||||
}
|
||||
|
||||
pub async fn blocklist(mut pool: &mut impl GetConn) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn blocklist(pool: &DbPool) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
instance::table
|
||||
.inner_join(federation_blocklist::table)
|
||||
.select(instance::all_columns)
|
||||
|
@ -78,8 +75,8 @@ impl Instance {
|
|||
.await
|
||||
}
|
||||
|
||||
pub async fn linked(mut pool: &mut impl GetConn) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn linked(pool: &DbPool) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
instance::table
|
||||
.left_join(federation_blocklist::table)
|
||||
.filter(federation_blocklist::id.is_null())
|
||||
|
|
|
@ -3,14 +3,14 @@ use crate::{
|
|||
newtypes::LanguageId,
|
||||
schema::language::dsl::{code, id, language},
|
||||
source::language::Language,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{result::Error, QueryDsl};
|
||||
use diesel_async::{AsyncPgConnection, RunQueryDsl};
|
||||
|
||||
impl Language {
|
||||
pub async fn read_all(mut pool: &mut impl GetConn) -> Result<Vec<Language>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read_all(pool: &DbPool) -> Result<Vec<Language>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
Self::read_all_conn(conn).await
|
||||
}
|
||||
|
||||
|
@ -18,21 +18,18 @@ impl Language {
|
|||
language.load::<Self>(conn).await
|
||||
}
|
||||
|
||||
pub async fn read_from_id(
|
||||
mut pool: &mut impl GetConn,
|
||||
id_: LanguageId,
|
||||
) -> Result<Language, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read_from_id(pool: &DbPool, id_: LanguageId) -> Result<Language, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
language.filter(id.eq(id_)).first::<Self>(conn).await
|
||||
}
|
||||
|
||||
/// Attempts to find the given language code and return its ID. If not found, returns none.
|
||||
pub async fn read_id_from_code(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
code_: Option<&str>,
|
||||
) -> Result<Option<LanguageId>, Error> {
|
||||
if let Some(code_) = code_ {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
Ok(
|
||||
language
|
||||
.filter(code.eq(code_))
|
||||
|
|
|
@ -1,38 +1,32 @@
|
|||
use crate::{
|
||||
schema::local_site::dsl::local_site,
|
||||
source::local_site::{LocalSite, LocalSiteInsertForm, LocalSiteUpdateForm},
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{dsl::insert_into, result::Error};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
||||
impl LocalSite {
|
||||
pub async fn create(
|
||||
mut pool: &mut impl GetConn,
|
||||
form: &LocalSiteInsertForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn create(pool: &DbPool, form: &LocalSiteInsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(local_site)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
pub async fn read(mut pool: &mut impl GetConn) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read(pool: &DbPool) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
local_site.first::<Self>(conn).await
|
||||
}
|
||||
pub async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
form: &LocalSiteUpdateForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn update(pool: &DbPool, form: &LocalSiteUpdateForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(local_site)
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
pub async fn delete(mut pool: &mut impl GetConn) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn delete(pool: &DbPool) -> Result<usize, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(local_site).execute(conn).await
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,36 +5,30 @@ use crate::{
|
|||
LocalSiteRateLimitInsertForm,
|
||||
LocalSiteRateLimitUpdateForm,
|
||||
},
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{dsl::insert_into, result::Error};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
||||
impl LocalSiteRateLimit {
|
||||
pub async fn read(mut pool: &mut impl GetConn) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read(pool: &DbPool) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
local_site_rate_limit::table.first::<Self>(conn).await
|
||||
}
|
||||
|
||||
pub async fn create(
|
||||
mut pool: &mut impl GetConn,
|
||||
form: &LocalSiteRateLimitInsertForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn create(pool: &DbPool, form: &LocalSiteRateLimitInsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(local_site_rate_limit::table)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
pub async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
form: &LocalSiteRateLimitUpdateForm,
|
||||
) -> Result<(), Error> {
|
||||
pub async fn update(pool: &DbPool, form: &LocalSiteRateLimitUpdateForm) -> Result<(), Error> {
|
||||
// avoid error "There are no changes to save. This query cannot be built"
|
||||
if form.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(local_site_rate_limit::table)
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
|
|
@ -13,7 +13,7 @@ use crate::{
|
|||
local_user::{LocalUser, LocalUserInsertForm, LocalUserUpdateForm},
|
||||
},
|
||||
traits::Crud,
|
||||
utils::{naive_now, DbPool, GetConn},
|
||||
utils::{get_conn, naive_now, DbPool},
|
||||
};
|
||||
use bcrypt::{hash, DEFAULT_COST};
|
||||
use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl};
|
||||
|
@ -21,11 +21,11 @@ use diesel_async::RunQueryDsl;
|
|||
|
||||
impl LocalUser {
|
||||
pub async fn update_password(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
local_user_id: LocalUserId,
|
||||
new_password: &str,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let password_hash = hash(new_password, DEFAULT_COST).expect("Couldn't hash password");
|
||||
|
||||
diesel::update(local_user.find(local_user_id))
|
||||
|
@ -37,10 +37,8 @@ impl LocalUser {
|
|||
.await
|
||||
}
|
||||
|
||||
pub async fn set_all_users_email_verified(
|
||||
mut pool: &mut impl GetConn,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn set_all_users_email_verified(pool: &DbPool) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(local_user)
|
||||
.set(email_verified.eq(true))
|
||||
.get_results::<Self>(conn)
|
||||
|
@ -48,18 +46,18 @@ impl LocalUser {
|
|||
}
|
||||
|
||||
pub async fn set_all_users_registration_applications_accepted(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(local_user)
|
||||
.set(accepted_application.eq(true))
|
||||
.get_results::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn is_email_taken(mut pool: &mut impl GetConn, email_: &str) -> Result<bool, Error> {
|
||||
pub async fn is_email_taken(pool: &DbPool, email_: &str) -> Result<bool, Error> {
|
||||
use diesel::dsl::{exists, select};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
select(exists(local_user.filter(email.eq(email_))))
|
||||
.get_result(conn)
|
||||
.await
|
||||
|
@ -71,18 +69,18 @@ impl Crud for LocalUser {
|
|||
type InsertForm = LocalUserInsertForm;
|
||||
type UpdateForm = LocalUserUpdateForm;
|
||||
type IdType = LocalUserId;
|
||||
async fn read(mut pool: &mut impl GetConn, local_user_id: LocalUserId) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn read(pool: &DbPool, local_user_id: LocalUserId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
local_user.find(local_user_id).first::<Self>(conn).await
|
||||
}
|
||||
async fn delete(mut pool: &mut impl GetConn, local_user_id: LocalUserId) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn delete(pool: &DbPool, local_user_id: LocalUserId) -> Result<usize, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(local_user.find(local_user_id))
|
||||
.execute(conn)
|
||||
.await
|
||||
}
|
||||
async fn create(mut pool: &mut impl GetConn, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn create(pool: &DbPool, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let mut form_with_encrypted_password = form.clone();
|
||||
let password_hash =
|
||||
hash(&form.password_encrypted, DEFAULT_COST).expect("Couldn't hash password");
|
||||
|
@ -106,11 +104,11 @@ impl Crud for LocalUser {
|
|||
Ok(local_user_)
|
||||
}
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
local_user_id: LocalUserId,
|
||||
form: &Self::UpdateForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(local_user.find(local_user_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
|
|
@ -32,7 +32,7 @@ use crate::{
|
|||
ModTransferCommunityForm,
|
||||
},
|
||||
traits::Crud,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{dsl::insert_into, result::Error, QueryDsl};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
@ -42,28 +42,24 @@ impl Crud for ModRemovePost {
|
|||
type InsertForm = ModRemovePostForm;
|
||||
type UpdateForm = ModRemovePostForm;
|
||||
type IdType = i32;
|
||||
async fn read(mut pool: &mut impl GetConn, from_id: i32) -> Result<Self, Error> {
|
||||
async fn read(pool: &DbPool, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::mod_remove_post::dsl::mod_remove_post;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
mod_remove_post.find(from_id).first::<Self>(conn).await
|
||||
}
|
||||
|
||||
async fn create(mut pool: &mut impl GetConn, form: &ModRemovePostForm) -> Result<Self, Error> {
|
||||
async fn create(pool: &DbPool, form: &ModRemovePostForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_remove_post::dsl::mod_remove_post;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(mod_remove_post)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
from_id: i32,
|
||||
form: &ModRemovePostForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn update(pool: &DbPool, from_id: i32, form: &ModRemovePostForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_remove_post::dsl::mod_remove_post;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(mod_remove_post.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -76,28 +72,24 @@ impl Crud for ModLockPost {
|
|||
type InsertForm = ModLockPostForm;
|
||||
type UpdateForm = ModLockPostForm;
|
||||
type IdType = i32;
|
||||
async fn read(mut pool: &mut impl GetConn, from_id: i32) -> Result<Self, Error> {
|
||||
async fn read(pool: &DbPool, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::mod_lock_post::dsl::mod_lock_post;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
mod_lock_post.find(from_id).first::<Self>(conn).await
|
||||
}
|
||||
|
||||
async fn create(mut pool: &mut impl GetConn, form: &ModLockPostForm) -> Result<Self, Error> {
|
||||
async fn create(pool: &DbPool, form: &ModLockPostForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_lock_post::dsl::mod_lock_post;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(mod_lock_post)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
from_id: i32,
|
||||
form: &ModLockPostForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn update(pool: &DbPool, from_id: i32, form: &ModLockPostForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_lock_post::dsl::mod_lock_post;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(mod_lock_post.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -110,28 +102,24 @@ impl Crud for ModFeaturePost {
|
|||
type InsertForm = ModFeaturePostForm;
|
||||
type UpdateForm = ModFeaturePostForm;
|
||||
type IdType = i32;
|
||||
async fn read(mut pool: &mut impl GetConn, from_id: i32) -> Result<Self, Error> {
|
||||
async fn read(pool: &DbPool, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::mod_feature_post::dsl::mod_feature_post;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
mod_feature_post.find(from_id).first::<Self>(conn).await
|
||||
}
|
||||
|
||||
async fn create(mut pool: &mut impl GetConn, form: &ModFeaturePostForm) -> Result<Self, Error> {
|
||||
async fn create(pool: &DbPool, form: &ModFeaturePostForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_feature_post::dsl::mod_feature_post;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(mod_feature_post)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
from_id: i32,
|
||||
form: &ModFeaturePostForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn update(pool: &DbPool, from_id: i32, form: &ModFeaturePostForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_feature_post::dsl::mod_feature_post;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(mod_feature_post.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -144,28 +132,24 @@ impl Crud for ModRemoveComment {
|
|||
type InsertForm = ModRemoveCommentForm;
|
||||
type UpdateForm = ModRemoveCommentForm;
|
||||
type IdType = i32;
|
||||
async fn read(mut pool: &mut impl GetConn, from_id: i32) -> Result<Self, Error> {
|
||||
async fn read(pool: &DbPool, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::mod_remove_comment::dsl::mod_remove_comment;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
mod_remove_comment.find(from_id).first::<Self>(conn).await
|
||||
}
|
||||
|
||||
async fn create(mut pool: &mut impl GetConn, form: &ModRemoveCommentForm) -> Result<Self, Error> {
|
||||
async fn create(pool: &DbPool, form: &ModRemoveCommentForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_remove_comment::dsl::mod_remove_comment;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(mod_remove_comment)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
from_id: i32,
|
||||
form: &ModRemoveCommentForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn update(pool: &DbPool, from_id: i32, form: &ModRemoveCommentForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_remove_comment::dsl::mod_remove_comment;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(mod_remove_comment.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -178,18 +162,15 @@ impl Crud for ModRemoveCommunity {
|
|||
type InsertForm = ModRemoveCommunityForm;
|
||||
type UpdateForm = ModRemoveCommunityForm;
|
||||
type IdType = i32;
|
||||
async fn read(mut pool: &mut impl GetConn, from_id: i32) -> Result<Self, Error> {
|
||||
async fn read(pool: &DbPool, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::mod_remove_community::dsl::mod_remove_community;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
mod_remove_community.find(from_id).first::<Self>(conn).await
|
||||
}
|
||||
|
||||
async fn create(
|
||||
mut pool: &mut impl GetConn,
|
||||
form: &ModRemoveCommunityForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn create(pool: &DbPool, form: &ModRemoveCommunityForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_remove_community::dsl::mod_remove_community;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(mod_remove_community)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -197,12 +178,12 @@ impl Crud for ModRemoveCommunity {
|
|||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
from_id: i32,
|
||||
form: &ModRemoveCommunityForm,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::mod_remove_community::dsl::mod_remove_community;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(mod_remove_community.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -215,21 +196,18 @@ impl Crud for ModBanFromCommunity {
|
|||
type InsertForm = ModBanFromCommunityForm;
|
||||
type UpdateForm = ModBanFromCommunityForm;
|
||||
type IdType = i32;
|
||||
async fn read(mut pool: &mut impl GetConn, from_id: i32) -> Result<Self, Error> {
|
||||
async fn read(pool: &DbPool, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::mod_ban_from_community::dsl::mod_ban_from_community;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
mod_ban_from_community
|
||||
.find(from_id)
|
||||
.first::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn create(
|
||||
mut pool: &mut impl GetConn,
|
||||
form: &ModBanFromCommunityForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn create(pool: &DbPool, form: &ModBanFromCommunityForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_ban_from_community::dsl::mod_ban_from_community;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(mod_ban_from_community)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -237,12 +215,12 @@ impl Crud for ModBanFromCommunity {
|
|||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
from_id: i32,
|
||||
form: &ModBanFromCommunityForm,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::mod_ban_from_community::dsl::mod_ban_from_community;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(mod_ban_from_community.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -255,28 +233,24 @@ impl Crud for ModBan {
|
|||
type InsertForm = ModBanForm;
|
||||
type UpdateForm = ModBanForm;
|
||||
type IdType = i32;
|
||||
async fn read(mut pool: &mut impl GetConn, from_id: i32) -> Result<Self, Error> {
|
||||
async fn read(pool: &DbPool, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::mod_ban::dsl::mod_ban;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
mod_ban.find(from_id).first::<Self>(conn).await
|
||||
}
|
||||
|
||||
async fn create(mut pool: &mut impl GetConn, form: &ModBanForm) -> Result<Self, Error> {
|
||||
async fn create(pool: &DbPool, form: &ModBanForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_ban::dsl::mod_ban;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(mod_ban)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
from_id: i32,
|
||||
form: &ModBanForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn update(pool: &DbPool, from_id: i32, form: &ModBanForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_ban::dsl::mod_ban;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(mod_ban.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -290,28 +264,24 @@ impl Crud for ModHideCommunity {
|
|||
type UpdateForm = ModHideCommunityForm;
|
||||
type IdType = i32;
|
||||
|
||||
async fn read(mut pool: &mut impl GetConn, from_id: i32) -> Result<Self, Error> {
|
||||
async fn read(pool: &DbPool, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::mod_hide_community::dsl::mod_hide_community;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
mod_hide_community.find(from_id).first::<Self>(conn).await
|
||||
}
|
||||
|
||||
async fn create(mut pool: &mut impl GetConn, form: &ModHideCommunityForm) -> Result<Self, Error> {
|
||||
async fn create(pool: &DbPool, form: &ModHideCommunityForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_hide_community::dsl::mod_hide_community;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(mod_hide_community)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
from_id: i32,
|
||||
form: &ModHideCommunityForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn update(pool: &DbPool, from_id: i32, form: &ModHideCommunityForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_hide_community::dsl::mod_hide_community;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(mod_hide_community.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -324,28 +294,24 @@ impl Crud for ModAddCommunity {
|
|||
type InsertForm = ModAddCommunityForm;
|
||||
type UpdateForm = ModAddCommunityForm;
|
||||
type IdType = i32;
|
||||
async fn read(mut pool: &mut impl GetConn, from_id: i32) -> Result<Self, Error> {
|
||||
async fn read(pool: &DbPool, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::mod_add_community::dsl::mod_add_community;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
mod_add_community.find(from_id).first::<Self>(conn).await
|
||||
}
|
||||
|
||||
async fn create(mut pool: &mut impl GetConn, form: &ModAddCommunityForm) -> Result<Self, Error> {
|
||||
async fn create(pool: &DbPool, form: &ModAddCommunityForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_add_community::dsl::mod_add_community;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(mod_add_community)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
from_id: i32,
|
||||
form: &ModAddCommunityForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn update(pool: &DbPool, from_id: i32, form: &ModAddCommunityForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_add_community::dsl::mod_add_community;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(mod_add_community.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -358,21 +324,18 @@ impl Crud for ModTransferCommunity {
|
|||
type InsertForm = ModTransferCommunityForm;
|
||||
type UpdateForm = ModTransferCommunityForm;
|
||||
type IdType = i32;
|
||||
async fn read(mut pool: &mut impl GetConn, from_id: i32) -> Result<Self, Error> {
|
||||
async fn read(pool: &DbPool, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::mod_transfer_community::dsl::mod_transfer_community;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
mod_transfer_community
|
||||
.find(from_id)
|
||||
.first::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn create(
|
||||
mut pool: &mut impl GetConn,
|
||||
form: &ModTransferCommunityForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn create(pool: &DbPool, form: &ModTransferCommunityForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_transfer_community::dsl::mod_transfer_community;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(mod_transfer_community)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -380,12 +343,12 @@ impl Crud for ModTransferCommunity {
|
|||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
from_id: i32,
|
||||
form: &ModTransferCommunityForm,
|
||||
) -> Result<Self, Error> {
|
||||
use crate::schema::mod_transfer_community::dsl::mod_transfer_community;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(mod_transfer_community.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -398,28 +361,24 @@ impl Crud for ModAdd {
|
|||
type InsertForm = ModAddForm;
|
||||
type UpdateForm = ModAddForm;
|
||||
type IdType = i32;
|
||||
async fn read(mut pool: &mut impl GetConn, from_id: i32) -> Result<Self, Error> {
|
||||
async fn read(pool: &DbPool, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::mod_add::dsl::mod_add;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
mod_add.find(from_id).first::<Self>(conn).await
|
||||
}
|
||||
|
||||
async fn create(mut pool: &mut impl GetConn, form: &ModAddForm) -> Result<Self, Error> {
|
||||
async fn create(pool: &DbPool, form: &ModAddForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_add::dsl::mod_add;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(mod_add)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
from_id: i32,
|
||||
form: &ModAddForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn update(pool: &DbPool, from_id: i32, form: &ModAddForm) -> Result<Self, Error> {
|
||||
use crate::schema::mod_add::dsl::mod_add;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(mod_add.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -432,28 +391,24 @@ impl Crud for AdminPurgePerson {
|
|||
type InsertForm = AdminPurgePersonForm;
|
||||
type UpdateForm = AdminPurgePersonForm;
|
||||
type IdType = i32;
|
||||
async fn read(mut pool: &mut impl GetConn, from_id: i32) -> Result<Self, Error> {
|
||||
async fn read(pool: &DbPool, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::admin_purge_person::dsl::admin_purge_person;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
admin_purge_person.find(from_id).first::<Self>(conn).await
|
||||
}
|
||||
|
||||
async fn create(mut pool: &mut impl GetConn, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
async fn create(pool: &DbPool, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
use crate::schema::admin_purge_person::dsl::admin_purge_person;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(admin_purge_person)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
from_id: i32,
|
||||
form: &Self::InsertForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn update(pool: &DbPool, from_id: i32, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
use crate::schema::admin_purge_person::dsl::admin_purge_person;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(admin_purge_person.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -466,31 +421,27 @@ impl Crud for AdminPurgeCommunity {
|
|||
type InsertForm = AdminPurgeCommunityForm;
|
||||
type UpdateForm = AdminPurgeCommunityForm;
|
||||
type IdType = i32;
|
||||
async fn read(mut pool: &mut impl GetConn, from_id: i32) -> Result<Self, Error> {
|
||||
async fn read(pool: &DbPool, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::admin_purge_community::dsl::admin_purge_community;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
admin_purge_community
|
||||
.find(from_id)
|
||||
.first::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn create(mut pool: &mut impl GetConn, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
async fn create(pool: &DbPool, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
use crate::schema::admin_purge_community::dsl::admin_purge_community;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(admin_purge_community)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
from_id: i32,
|
||||
form: &Self::InsertForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn update(pool: &DbPool, from_id: i32, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
use crate::schema::admin_purge_community::dsl::admin_purge_community;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(admin_purge_community.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -503,28 +454,24 @@ impl Crud for AdminPurgePost {
|
|||
type InsertForm = AdminPurgePostForm;
|
||||
type UpdateForm = AdminPurgePostForm;
|
||||
type IdType = i32;
|
||||
async fn read(mut pool: &mut impl GetConn, from_id: i32) -> Result<Self, Error> {
|
||||
async fn read(pool: &DbPool, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::admin_purge_post::dsl::admin_purge_post;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
admin_purge_post.find(from_id).first::<Self>(conn).await
|
||||
}
|
||||
|
||||
async fn create(mut pool: &mut impl GetConn, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
async fn create(pool: &DbPool, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
use crate::schema::admin_purge_post::dsl::admin_purge_post;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(admin_purge_post)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
from_id: i32,
|
||||
form: &Self::InsertForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn update(pool: &DbPool, from_id: i32, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
use crate::schema::admin_purge_post::dsl::admin_purge_post;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(admin_purge_post.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -537,28 +484,24 @@ impl Crud for AdminPurgeComment {
|
|||
type InsertForm = AdminPurgeCommentForm;
|
||||
type UpdateForm = AdminPurgeCommentForm;
|
||||
type IdType = i32;
|
||||
async fn read(mut pool: &mut impl GetConn, from_id: i32) -> Result<Self, Error> {
|
||||
async fn read(pool: &DbPool, from_id: i32) -> Result<Self, Error> {
|
||||
use crate::schema::admin_purge_comment::dsl::admin_purge_comment;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
admin_purge_comment.find(from_id).first::<Self>(conn).await
|
||||
}
|
||||
|
||||
async fn create(mut pool: &mut impl GetConn, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
async fn create(pool: &DbPool, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
use crate::schema::admin_purge_comment::dsl::admin_purge_comment;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(admin_purge_comment)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
from_id: i32,
|
||||
form: &Self::InsertForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn update(pool: &DbPool, from_id: i32, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
use crate::schema::admin_purge_comment::dsl::admin_purge_comment;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(admin_purge_comment.find(from_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::{
|
|||
},
|
||||
source::password_reset_request::{PasswordResetRequest, PasswordResetRequestForm},
|
||||
traits::Crud,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{
|
||||
dsl::{insert_into, now, IntervalDsl},
|
||||
|
@ -24,32 +24,26 @@ impl Crud for PasswordResetRequest {
|
|||
type InsertForm = PasswordResetRequestForm;
|
||||
type UpdateForm = PasswordResetRequestForm;
|
||||
type IdType = i32;
|
||||
async fn read(
|
||||
mut pool: &mut impl GetConn,
|
||||
password_reset_request_id: i32,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn read(pool: &DbPool, password_reset_request_id: i32) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
password_reset_request
|
||||
.find(password_reset_request_id)
|
||||
.first::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
async fn create(
|
||||
mut pool: &mut impl GetConn,
|
||||
form: &PasswordResetRequestForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn create(pool: &DbPool, form: &PasswordResetRequestForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(password_reset_request)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
password_reset_request_id: i32,
|
||||
form: &PasswordResetRequestForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(password_reset_request.find(password_reset_request_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -59,7 +53,7 @@ impl Crud for PasswordResetRequest {
|
|||
|
||||
impl PasswordResetRequest {
|
||||
pub async fn create_token(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
from_local_user_id: LocalUserId,
|
||||
token: &str,
|
||||
) -> Result<PasswordResetRequest, Error> {
|
||||
|
@ -74,11 +68,8 @@ impl PasswordResetRequest {
|
|||
|
||||
Self::create(pool, &form).await
|
||||
}
|
||||
pub async fn read_from_token(
|
||||
mut pool: &mut impl GetConn,
|
||||
token: &str,
|
||||
) -> Result<PasswordResetRequest, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read_from_token(pool: &DbPool, token: &str) -> Result<PasswordResetRequest, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let mut hasher = Sha256::new();
|
||||
hasher.update(token);
|
||||
let token_hash: String = bytes_to_hex(hasher.finalize().to_vec());
|
||||
|
@ -90,10 +81,10 @@ impl PasswordResetRequest {
|
|||
}
|
||||
|
||||
pub async fn get_recent_password_resets_count(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
user_id: LocalUserId,
|
||||
) -> Result<i64, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
password_reset_request
|
||||
.filter(local_user_id.eq(user_id))
|
||||
.filter(published.gt(now - 1.days()))
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::{
|
|||
PersonUpdateForm,
|
||||
},
|
||||
traits::{ApubActor, Crud, Followable},
|
||||
utils::{functions::lower, naive_now, DbPool, GetConn},
|
||||
utils::{functions::lower, get_conn, naive_now, DbPool},
|
||||
};
|
||||
use diesel::{dsl::insert_into, result::Error, ExpressionMethods, JoinOnDsl, QueryDsl};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
@ -19,33 +19,33 @@ impl Crud for Person {
|
|||
type InsertForm = PersonInsertForm;
|
||||
type UpdateForm = PersonUpdateForm;
|
||||
type IdType = PersonId;
|
||||
async fn read(mut pool: &mut impl GetConn, person_id: PersonId) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn read(pool: &DbPool, person_id: PersonId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
person::table
|
||||
.filter(person::deleted.eq(false))
|
||||
.find(person_id)
|
||||
.first::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
async fn delete(mut pool: &mut impl GetConn, person_id: PersonId) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn delete(pool: &DbPool, person_id: PersonId) -> Result<usize, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(person::table.find(person_id))
|
||||
.execute(conn)
|
||||
.await
|
||||
}
|
||||
async fn create(mut pool: &mut impl GetConn, form: &PersonInsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn create(pool: &DbPool, form: &PersonInsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(person::table)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
person_id: PersonId,
|
||||
form: &PersonUpdateForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(person::table.find(person_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -57,8 +57,8 @@ impl Person {
|
|||
/// Update or insert the person.
|
||||
///
|
||||
/// This is necessary for federation, because Activitypub doesnt distinguish between these actions.
|
||||
pub async fn upsert(mut pool: &mut impl GetConn, form: &PersonInsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn upsert(pool: &DbPool, form: &PersonInsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(person::table)
|
||||
.values(form)
|
||||
.on_conflict(person::actor_id)
|
||||
|
@ -67,11 +67,8 @@ impl Person {
|
|||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
pub async fn delete_account(
|
||||
mut pool: &mut impl GetConn,
|
||||
person_id: PersonId,
|
||||
) -> Result<Person, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn delete_account(pool: &DbPool, person_id: PersonId) -> Result<Person, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
// Set the local user info to none
|
||||
diesel::update(local_user::table.filter(local_user::person_id.eq(person_id)))
|
||||
|
@ -107,11 +104,8 @@ pub fn is_banned(banned_: bool, expires: Option<chrono::NaiveDateTime>) -> bool
|
|||
|
||||
#[async_trait]
|
||||
impl ApubActor for Person {
|
||||
async fn read_from_apub_id(
|
||||
mut pool: &mut impl GetConn,
|
||||
object_id: &DbUrl,
|
||||
) -> Result<Option<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn read_from_apub_id(pool: &DbPool, object_id: &DbUrl) -> Result<Option<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
Ok(
|
||||
person::table
|
||||
.filter(person::deleted.eq(false))
|
||||
|
@ -124,11 +118,11 @@ impl ApubActor for Person {
|
|||
}
|
||||
|
||||
async fn read_from_name(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
from_name: &str,
|
||||
include_deleted: bool,
|
||||
) -> Result<Person, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let mut q = person::table
|
||||
.into_boxed()
|
||||
.filter(person::local.eq(true))
|
||||
|
@ -140,11 +134,11 @@ impl ApubActor for Person {
|
|||
}
|
||||
|
||||
async fn read_from_name_and_domain(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
person_name: &str,
|
||||
for_domain: &str,
|
||||
) -> Result<Person, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
person::table
|
||||
.inner_join(instance::table)
|
||||
|
@ -159,9 +153,9 @@ impl ApubActor for Person {
|
|||
#[async_trait]
|
||||
impl Followable for PersonFollower {
|
||||
type Form = PersonFollowerForm;
|
||||
async fn follow(mut pool: &mut impl GetConn, form: &PersonFollowerForm) -> Result<Self, Error> {
|
||||
async fn follow(pool: &DbPool, form: &PersonFollowerForm) -> Result<Self, Error> {
|
||||
use crate::schema::person_follower::dsl::{follower_id, person_follower, person_id};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(person_follower)
|
||||
.values(form)
|
||||
.on_conflict((follower_id, person_id))
|
||||
|
@ -170,19 +164,12 @@ impl Followable for PersonFollower {
|
|||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
async fn follow_accepted(
|
||||
_: &mut impl GetConn,
|
||||
_: CommunityId,
|
||||
_: PersonId,
|
||||
) -> Result<Self, Error> {
|
||||
async fn follow_accepted(_: &DbPool, _: CommunityId, _: PersonId) -> Result<Self, Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
async fn unfollow(
|
||||
mut pool: &mut impl GetConn,
|
||||
form: &PersonFollowerForm,
|
||||
) -> Result<usize, Error> {
|
||||
async fn unfollow(pool: &DbPool, form: &PersonFollowerForm) -> Result<usize, Error> {
|
||||
use crate::schema::person_follower::dsl::{follower_id, person_follower, person_id};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(
|
||||
person_follower
|
||||
.filter(follower_id.eq(&form.follower_id))
|
||||
|
@ -195,10 +182,10 @@ impl Followable for PersonFollower {
|
|||
|
||||
impl PersonFollower {
|
||||
pub async fn list_followers(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_person_id: PersonId,
|
||||
) -> Result<Vec<Person>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
person_follower::table
|
||||
.inner_join(person::table.on(person_follower::follower_id.eq(person::id)))
|
||||
.filter(person_follower::person_id.eq(for_person_id))
|
||||
|
|
|
@ -3,18 +3,18 @@ use crate::{
|
|||
schema::person_block::dsl::{person_block, person_id, target_id},
|
||||
source::person_block::{PersonBlock, PersonBlockForm},
|
||||
traits::Blockable,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
||||
impl PersonBlock {
|
||||
pub async fn read(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_person_id: PersonId,
|
||||
for_recipient_id: PersonId,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
person_block
|
||||
.filter(person_id.eq(for_person_id))
|
||||
.filter(target_id.eq(for_recipient_id))
|
||||
|
@ -26,11 +26,8 @@ impl PersonBlock {
|
|||
#[async_trait]
|
||||
impl Blockable for PersonBlock {
|
||||
type Form = PersonBlockForm;
|
||||
async fn block(
|
||||
mut pool: &mut impl GetConn,
|
||||
person_block_form: &PersonBlockForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn block(pool: &DbPool, person_block_form: &PersonBlockForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(person_block)
|
||||
.values(person_block_form)
|
||||
.on_conflict((person_id, target_id))
|
||||
|
@ -39,11 +36,8 @@ impl Blockable for PersonBlock {
|
|||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
async fn unblock(
|
||||
mut pool: &mut impl GetConn,
|
||||
person_block_form: &Self::Form,
|
||||
) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn unblock(pool: &DbPool, person_block_form: &Self::Form) -> Result<usize, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(
|
||||
person_block
|
||||
.filter(person_id.eq(person_block_form.person_id))
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::{
|
|||
schema::person_mention::dsl::{comment_id, person_mention, read, recipient_id},
|
||||
source::person_mention::{PersonMention, PersonMentionInsertForm, PersonMentionUpdateForm},
|
||||
traits::Crud,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
@ -13,22 +13,16 @@ impl Crud for PersonMention {
|
|||
type InsertForm = PersonMentionInsertForm;
|
||||
type UpdateForm = PersonMentionUpdateForm;
|
||||
type IdType = PersonMentionId;
|
||||
async fn read(
|
||||
mut pool: &mut impl GetConn,
|
||||
person_mention_id: PersonMentionId,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn read(pool: &DbPool, person_mention_id: PersonMentionId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
person_mention
|
||||
.find(person_mention_id)
|
||||
.first::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn create(
|
||||
mut pool: &mut impl GetConn,
|
||||
person_mention_form: &Self::InsertForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn create(pool: &DbPool, person_mention_form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
// since the return here isnt utilized, we dont need to do an update
|
||||
// but get_result doesnt return the existing row here
|
||||
insert_into(person_mention)
|
||||
|
@ -41,11 +35,11 @@ impl Crud for PersonMention {
|
|||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
person_mention_id: PersonMentionId,
|
||||
person_mention_form: &Self::UpdateForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(person_mention.find(person_mention_id))
|
||||
.set(person_mention_form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -55,10 +49,10 @@ impl Crud for PersonMention {
|
|||
|
||||
impl PersonMention {
|
||||
pub async fn mark_all_as_read(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_recipient_id: PersonId,
|
||||
) -> Result<Vec<PersonMention>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(
|
||||
person_mention
|
||||
.filter(recipient_id.eq(for_recipient_id))
|
||||
|
@ -70,11 +64,11 @@ impl PersonMention {
|
|||
}
|
||||
|
||||
pub async fn read_by_comment_and_person(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_comment_id: CommentId,
|
||||
for_recipient_id: PersonId,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
person_mention
|
||||
.filter(comment_id.eq(for_comment_id))
|
||||
.filter(recipient_id.eq(for_recipient_id))
|
||||
|
|
|
@ -27,7 +27,7 @@ use crate::{
|
|||
PostUpdateForm,
|
||||
},
|
||||
traits::{Crud, Likeable, Readable, Saveable},
|
||||
utils::{naive_now, DbPool, GetConn, DELETED_REPLACEMENT_TEXT, FETCH_LIMIT_MAX},
|
||||
utils::{get_conn, naive_now, DbPool, DELETED_REPLACEMENT_TEXT, FETCH_LIMIT_MAX},
|
||||
};
|
||||
use ::url::Url;
|
||||
use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl, TextExpressionMethods};
|
||||
|
@ -38,18 +38,18 @@ impl Crud for Post {
|
|||
type InsertForm = PostInsertForm;
|
||||
type UpdateForm = PostUpdateForm;
|
||||
type IdType = PostId;
|
||||
async fn read(mut pool: &mut impl GetConn, post_id: PostId) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn read(pool: &DbPool, post_id: PostId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
post.find(post_id).first::<Self>(conn).await
|
||||
}
|
||||
|
||||
async fn delete(mut pool: &mut impl GetConn, post_id: PostId) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn delete(pool: &DbPool, post_id: PostId) -> Result<usize, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(post.find(post_id)).execute(conn).await
|
||||
}
|
||||
|
||||
async fn create(mut pool: &mut impl GetConn, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn create(pool: &DbPool, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(post)
|
||||
.values(form)
|
||||
.on_conflict(ap_id)
|
||||
|
@ -60,11 +60,11 @@ impl Crud for Post {
|
|||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
post_id: PostId,
|
||||
new_post: &Self::UpdateForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(post.find(post_id))
|
||||
.set(new_post)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -74,10 +74,10 @@ impl Crud for Post {
|
|||
|
||||
impl Post {
|
||||
pub async fn list_for_community(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
the_community_id: CommunityId,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
post
|
||||
.filter(community_id.eq(the_community_id))
|
||||
.filter(deleted.eq(false))
|
||||
|
@ -90,10 +90,10 @@ impl Post {
|
|||
}
|
||||
|
||||
pub async fn list_featured_for_community(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
the_community_id: CommunityId,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
post
|
||||
.filter(community_id.eq(the_community_id))
|
||||
.filter(deleted.eq(false))
|
||||
|
@ -106,10 +106,10 @@ impl Post {
|
|||
}
|
||||
|
||||
pub async fn permadelete_for_creator(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_creator_id: PersonId,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
diesel::update(post.filter(creator_id.eq(for_creator_id)))
|
||||
.set((
|
||||
|
@ -124,12 +124,12 @@ impl Post {
|
|||
}
|
||||
|
||||
pub async fn update_removed_for_creator(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_creator_id: PersonId,
|
||||
for_community_id: Option<CommunityId>,
|
||||
new_removed: bool,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
let mut update = diesel::update(post).into_boxed();
|
||||
update = update.filter(creator_id.eq(for_creator_id));
|
||||
|
@ -148,11 +148,8 @@ impl Post {
|
|||
person_id == post_creator_id
|
||||
}
|
||||
|
||||
pub async fn read_from_apub_id(
|
||||
mut pool: &mut impl GetConn,
|
||||
object_id: Url,
|
||||
) -> Result<Option<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read_from_apub_id(pool: &DbPool, object_id: Url) -> Result<Option<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let object_id: DbUrl = object_id.into();
|
||||
Ok(
|
||||
post
|
||||
|
@ -165,10 +162,10 @@ impl Post {
|
|||
}
|
||||
|
||||
pub async fn fetch_pictrs_posts_for_creator(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_creator_id: PersonId,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let pictrs_search = "%pictrs/image%";
|
||||
|
||||
post
|
||||
|
@ -180,10 +177,10 @@ impl Post {
|
|||
|
||||
/// Sets the url and thumbnails fields to None
|
||||
pub async fn remove_pictrs_post_images_and_thumbnails_for_creator(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_creator_id: PersonId,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let pictrs_search = "%pictrs/image%";
|
||||
|
||||
diesel::update(
|
||||
|
@ -200,10 +197,10 @@ impl Post {
|
|||
}
|
||||
|
||||
pub async fn fetch_pictrs_posts_for_community(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_community_id: CommunityId,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let pictrs_search = "%pictrs/image%";
|
||||
post
|
||||
.filter(community_id.eq(for_community_id))
|
||||
|
@ -214,10 +211,10 @@ impl Post {
|
|||
|
||||
/// Sets the url and thumbnails fields to None
|
||||
pub async fn remove_pictrs_post_images_and_thumbnails_for_community(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_community_id: CommunityId,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let pictrs_search = "%pictrs/image%";
|
||||
|
||||
diesel::update(
|
||||
|
@ -238,9 +235,9 @@ impl Post {
|
|||
impl Likeable for PostLike {
|
||||
type Form = PostLikeForm;
|
||||
type IdType = PostId;
|
||||
async fn like(mut pool: &mut impl GetConn, post_like_form: &PostLikeForm) -> Result<Self, Error> {
|
||||
async fn like(pool: &DbPool, post_like_form: &PostLikeForm) -> Result<Self, Error> {
|
||||
use crate::schema::post_like::dsl::{person_id, post_id, post_like};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(post_like)
|
||||
.values(post_like_form)
|
||||
.on_conflict((post_id, person_id))
|
||||
|
@ -249,13 +246,9 @@ impl Likeable for PostLike {
|
|||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
async fn remove(
|
||||
mut pool: &mut impl GetConn,
|
||||
person_id: PersonId,
|
||||
post_id: PostId,
|
||||
) -> Result<usize, Error> {
|
||||
async fn remove(pool: &DbPool, person_id: PersonId, post_id: PostId) -> Result<usize, Error> {
|
||||
use crate::schema::post_like::dsl;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(
|
||||
dsl::post_like
|
||||
.filter(dsl::post_id.eq(post_id))
|
||||
|
@ -269,12 +262,9 @@ impl Likeable for PostLike {
|
|||
#[async_trait]
|
||||
impl Saveable for PostSaved {
|
||||
type Form = PostSavedForm;
|
||||
async fn save(
|
||||
mut pool: &mut impl GetConn,
|
||||
post_saved_form: &PostSavedForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn save(pool: &DbPool, post_saved_form: &PostSavedForm) -> Result<Self, Error> {
|
||||
use crate::schema::post_saved::dsl::{person_id, post_id, post_saved};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(post_saved)
|
||||
.values(post_saved_form)
|
||||
.on_conflict((post_id, person_id))
|
||||
|
@ -283,12 +273,9 @@ impl Saveable for PostSaved {
|
|||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
async fn unsave(
|
||||
mut pool: &mut impl GetConn,
|
||||
post_saved_form: &PostSavedForm,
|
||||
) -> Result<usize, Error> {
|
||||
async fn unsave(pool: &DbPool, post_saved_form: &PostSavedForm) -> Result<usize, Error> {
|
||||
use crate::schema::post_saved::dsl::{person_id, post_id, post_saved};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(
|
||||
post_saved
|
||||
.filter(post_id.eq(post_saved_form.post_id))
|
||||
|
@ -302,12 +289,9 @@ impl Saveable for PostSaved {
|
|||
#[async_trait]
|
||||
impl Readable for PostRead {
|
||||
type Form = PostReadForm;
|
||||
async fn mark_as_read(
|
||||
mut pool: &mut impl GetConn,
|
||||
post_read_form: &PostReadForm,
|
||||
) -> Result<Self, Error> {
|
||||
async fn mark_as_read(pool: &DbPool, post_read_form: &PostReadForm) -> Result<Self, Error> {
|
||||
use crate::schema::post_read::dsl::{person_id, post_id, post_read};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(post_read)
|
||||
.values(post_read_form)
|
||||
.on_conflict((post_id, person_id))
|
||||
|
@ -317,12 +301,9 @@ impl Readable for PostRead {
|
|||
.await
|
||||
}
|
||||
|
||||
async fn mark_as_unread(
|
||||
mut pool: &mut impl GetConn,
|
||||
post_read_form: &PostReadForm,
|
||||
) -> Result<usize, Error> {
|
||||
async fn mark_as_unread(pool: &DbPool, post_read_form: &PostReadForm) -> Result<usize, Error> {
|
||||
use crate::schema::post_read::dsl::{person_id, post_id, post_read};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(
|
||||
post_read
|
||||
.filter(post_id.eq(post_read_form.post_id))
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::{
|
|||
schema::post_report::dsl::{post_report, resolved, resolver_id, updated},
|
||||
source::post_report::{PostReport, PostReportForm},
|
||||
traits::Reportable,
|
||||
utils::{naive_now, DbPool, GetConn},
|
||||
utils::{get_conn, naive_now, DbPool},
|
||||
};
|
||||
use diesel::{
|
||||
dsl::{insert_into, update},
|
||||
|
@ -18,11 +18,8 @@ impl Reportable for PostReport {
|
|||
type Form = PostReportForm;
|
||||
type IdType = PostReportId;
|
||||
|
||||
async fn report(
|
||||
mut pool: &mut impl GetConn,
|
||||
post_report_form: &PostReportForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn report(pool: &DbPool, post_report_form: &PostReportForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(post_report)
|
||||
.values(post_report_form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -30,11 +27,11 @@ impl Reportable for PostReport {
|
|||
}
|
||||
|
||||
async fn resolve(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
report_id: Self::IdType,
|
||||
by_resolver_id: PersonId,
|
||||
) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
update(post_report.find(report_id))
|
||||
.set((
|
||||
resolved.eq(true),
|
||||
|
@ -46,11 +43,11 @@ impl Reportable for PostReport {
|
|||
}
|
||||
|
||||
async fn unresolve(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
report_id: Self::IdType,
|
||||
by_resolver_id: PersonId,
|
||||
) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
update(post_report.find(report_id))
|
||||
.set((
|
||||
resolved.eq(false),
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::{
|
|||
schema::private_message::dsl::{ap_id, private_message, read, recipient_id},
|
||||
source::private_message::{PrivateMessage, PrivateMessageInsertForm, PrivateMessageUpdateForm},
|
||||
traits::Crud,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
@ -15,19 +15,16 @@ impl Crud for PrivateMessage {
|
|||
type InsertForm = PrivateMessageInsertForm;
|
||||
type UpdateForm = PrivateMessageUpdateForm;
|
||||
type IdType = PrivateMessageId;
|
||||
async fn read(
|
||||
mut pool: &mut impl GetConn,
|
||||
private_message_id: PrivateMessageId,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn read(pool: &DbPool, private_message_id: PrivateMessageId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
private_message
|
||||
.find(private_message_id)
|
||||
.first::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn create(mut pool: &mut impl GetConn, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn create(pool: &DbPool, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(private_message)
|
||||
.values(form)
|
||||
.on_conflict(ap_id)
|
||||
|
@ -38,18 +35,18 @@ impl Crud for PrivateMessage {
|
|||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
private_message_id: PrivateMessageId,
|
||||
form: &Self::UpdateForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(private_message.find(private_message_id))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
async fn delete(mut pool: &mut impl GetConn, pm_id: Self::IdType) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn delete(pool: &DbPool, pm_id: Self::IdType) -> Result<usize, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(private_message.find(pm_id))
|
||||
.execute(conn)
|
||||
.await
|
||||
|
@ -58,10 +55,10 @@ impl Crud for PrivateMessage {
|
|||
|
||||
impl PrivateMessage {
|
||||
pub async fn mark_all_as_read(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_recipient_id: PersonId,
|
||||
) -> Result<Vec<PrivateMessage>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(
|
||||
private_message
|
||||
.filter(recipient_id.eq(for_recipient_id))
|
||||
|
@ -73,10 +70,10 @@ impl PrivateMessage {
|
|||
}
|
||||
|
||||
pub async fn read_from_apub_id(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
object_id: Url,
|
||||
) -> Result<Option<Self>, LemmyError> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let object_id: DbUrl = object_id.into();
|
||||
Ok(
|
||||
private_message
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::{
|
|||
schema::private_message_report::dsl::{private_message_report, resolved, resolver_id, updated},
|
||||
source::private_message_report::{PrivateMessageReport, PrivateMessageReportForm},
|
||||
traits::Reportable,
|
||||
utils::{naive_now, DbPool, GetConn},
|
||||
utils::{get_conn, naive_now, DbPool},
|
||||
};
|
||||
use diesel::{
|
||||
dsl::{insert_into, update},
|
||||
|
@ -18,11 +18,8 @@ impl Reportable for PrivateMessageReport {
|
|||
type Form = PrivateMessageReportForm;
|
||||
type IdType = PrivateMessageReportId;
|
||||
|
||||
async fn report(
|
||||
mut pool: &mut impl GetConn,
|
||||
pm_report_form: &PrivateMessageReportForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn report(pool: &DbPool, pm_report_form: &PrivateMessageReportForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(private_message_report)
|
||||
.values(pm_report_form)
|
||||
.get_result::<Self>(conn)
|
||||
|
@ -30,11 +27,11 @@ impl Reportable for PrivateMessageReport {
|
|||
}
|
||||
|
||||
async fn resolve(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
report_id: Self::IdType,
|
||||
by_resolver_id: PersonId,
|
||||
) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
update(private_message_report.find(report_id))
|
||||
.set((
|
||||
resolved.eq(true),
|
||||
|
@ -46,11 +43,11 @@ impl Reportable for PrivateMessageReport {
|
|||
}
|
||||
|
||||
async fn unresolve(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
report_id: Self::IdType,
|
||||
by_resolver_id: PersonId,
|
||||
) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
update(private_message_report.find(report_id))
|
||||
.set((
|
||||
resolved.eq(false),
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::{
|
|||
RegistrationApplicationUpdateForm,
|
||||
},
|
||||
traits::Crud,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{insert_into, result::Error, ExpressionMethods, QueryDsl};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
@ -18,33 +18,33 @@ impl Crud for RegistrationApplication {
|
|||
type UpdateForm = RegistrationApplicationUpdateForm;
|
||||
type IdType = i32;
|
||||
|
||||
async fn create(mut pool: &mut impl GetConn, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn create(pool: &DbPool, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
insert_into(registration_application)
|
||||
.values(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn read(mut pool: &mut impl GetConn, id_: Self::IdType) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn read(pool: &DbPool, id_: Self::IdType) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
registration_application.find(id_).first::<Self>(conn).await
|
||||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
id_: Self::IdType,
|
||||
form: &Self::UpdateForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(registration_application.find(id_))
|
||||
.set(form)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn delete(mut pool: &mut impl GetConn, id_: Self::IdType) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn delete(pool: &DbPool, id_: Self::IdType) -> Result<usize, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(registration_application.find(id_))
|
||||
.execute(conn)
|
||||
.await
|
||||
|
@ -53,10 +53,10 @@ impl Crud for RegistrationApplication {
|
|||
|
||||
impl RegistrationApplication {
|
||||
pub async fn find_by_local_user_id(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
local_user_id_: LocalUserId,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
registration_application
|
||||
.filter(local_user_id.eq(local_user_id_))
|
||||
.first::<Self>(conn)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{
|
||||
schema::secret::dsl::secret,
|
||||
source::secret::Secret,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::result::Error;
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
@ -9,12 +9,12 @@ use diesel_async::RunQueryDsl;
|
|||
impl Secret {
|
||||
/// Initialize the Secrets from the DB.
|
||||
/// Warning: You should only call this once.
|
||||
pub async fn init(mut pool: &mut impl GetConn) -> Result<Secret, Error> {
|
||||
pub async fn init(pool: &DbPool) -> Result<Secret, Error> {
|
||||
Self::read_secrets(pool).await
|
||||
}
|
||||
|
||||
async fn read_secrets(mut pool: &mut impl GetConn) -> Result<Secret, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn read_secrets(pool: &DbPool) -> Result<Secret, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
secret.first::<Secret>(conn).await
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::{
|
|||
site::{Site, SiteInsertForm, SiteUpdateForm},
|
||||
},
|
||||
traits::Crud,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl};
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
@ -19,12 +19,12 @@ impl Crud for Site {
|
|||
type IdType = SiteId;
|
||||
|
||||
/// Use SiteView::read_local, or Site::read_from_apub_id instead
|
||||
async fn read(_pool: &mut impl GetConn, _site_id: SiteId) -> Result<Self, Error> {
|
||||
async fn read(_pool: &DbPool, _site_id: SiteId) -> Result<Self, Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
async fn create(mut pool: &mut impl GetConn, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn create(pool: &DbPool, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let is_new_site = match &form.actor_id {
|
||||
Some(id_) => Site::read_from_apub_id(pool, id_).await?.is_none(),
|
||||
None => true,
|
||||
|
@ -48,29 +48,26 @@ impl Crud for Site {
|
|||
}
|
||||
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
site_id: SiteId,
|
||||
new_site: &Self::UpdateForm,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::update(site.find(site_id))
|
||||
.set(new_site)
|
||||
.get_result::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn delete(mut pool: &mut impl GetConn, site_id: SiteId) -> Result<usize, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn delete(pool: &DbPool, site_id: SiteId) -> Result<usize, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
diesel::delete(site.find(site_id)).execute(conn).await
|
||||
}
|
||||
}
|
||||
|
||||
impl Site {
|
||||
pub async fn read_from_apub_id(
|
||||
mut pool: &mut impl GetConn,
|
||||
object_id: &DbUrl,
|
||||
) -> Result<Option<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read_from_apub_id(pool: &DbPool, object_id: &DbUrl) -> Result<Option<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
Ok(
|
||||
site
|
||||
.filter(actor_id.eq(object_id))
|
||||
|
@ -82,8 +79,8 @@ impl Site {
|
|||
}
|
||||
|
||||
// TODO this needs fixed
|
||||
pub async fn read_remote_sites(mut pool: &mut impl GetConn) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read_remote_sites(pool: &DbPool) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
site.order_by(id).offset(1).get_results::<Self>(conn).await
|
||||
}
|
||||
|
||||
|
|
|
@ -2,18 +2,18 @@ use crate::{
|
|||
newtypes::LocalSiteId,
|
||||
schema::tagline::dsl::{local_site_id, tagline},
|
||||
source::tagline::{Tagline, TaglineForm},
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use diesel::{insert_into, result::Error, ExpressionMethods, QueryDsl};
|
||||
use diesel_async::{AsyncPgConnection, RunQueryDsl};
|
||||
|
||||
impl Tagline {
|
||||
pub async fn replace(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
for_local_site_id: LocalSiteId,
|
||||
list_content: Option<Vec<String>>,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
if let Some(list) = list_content {
|
||||
conn
|
||||
.build_transaction()
|
||||
|
@ -54,11 +54,8 @@ impl Tagline {
|
|||
.get_results::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
pub async fn get_all(
|
||||
mut pool: &mut impl GetConn,
|
||||
for_local_site_id: LocalSiteId,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn get_all(pool: &DbPool, for_local_site_id: LocalSiteId) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
Self::get_all_conn(conn, for_local_site_id).await
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
newtypes::{CommunityId, DbUrl, PersonId},
|
||||
utils::{DbPool, GetConn},
|
||||
utils::DbPool,
|
||||
};
|
||||
use diesel::result::Error;
|
||||
|
||||
|
@ -9,21 +9,17 @@ pub trait Crud {
|
|||
type InsertForm;
|
||||
type UpdateForm;
|
||||
type IdType;
|
||||
async fn create(mut pool: &mut impl GetConn, form: &Self::InsertForm) -> Result<Self, Error>
|
||||
async fn create(pool: &DbPool, form: &Self::InsertForm) -> Result<Self, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
async fn read(mut pool: &mut impl GetConn, id: Self::IdType) -> Result<Self, Error>
|
||||
async fn read(pool: &DbPool, id: Self::IdType) -> Result<Self, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
/// when you want to null out a column, you have to send Some(None)), since sending None means you just don't want to update that column.
|
||||
async fn update(
|
||||
mut pool: &mut impl GetConn,
|
||||
id: Self::IdType,
|
||||
form: &Self::UpdateForm,
|
||||
) -> Result<Self, Error>
|
||||
async fn update(pool: &DbPool, id: Self::IdType, form: &Self::UpdateForm) -> Result<Self, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
async fn delete(_pool: &mut impl GetConn, _id: Self::IdType) -> Result<usize, Error>
|
||||
async fn delete(_pool: &DbPool, _id: Self::IdType) -> Result<usize, Error>
|
||||
where
|
||||
Self: Sized,
|
||||
Self::IdType: Send,
|
||||
|
@ -35,17 +31,17 @@ pub trait Crud {
|
|||
#[async_trait]
|
||||
pub trait Followable {
|
||||
type Form;
|
||||
async fn follow(mut pool: &mut impl GetConn, form: &Self::Form) -> Result<Self, Error>
|
||||
async fn follow(pool: &DbPool, form: &Self::Form) -> Result<Self, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
async fn follow_accepted(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
community_id: CommunityId,
|
||||
person_id: PersonId,
|
||||
) -> Result<Self, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
async fn unfollow(mut pool: &mut impl GetConn, form: &Self::Form) -> Result<usize, Error>
|
||||
async fn unfollow(pool: &DbPool, form: &Self::Form) -> Result<usize, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
}
|
||||
|
@ -53,10 +49,10 @@ pub trait Followable {
|
|||
#[async_trait]
|
||||
pub trait Joinable {
|
||||
type Form;
|
||||
async fn join(mut pool: &mut impl GetConn, form: &Self::Form) -> Result<Self, Error>
|
||||
async fn join(pool: &DbPool, form: &Self::Form) -> Result<Self, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
async fn leave(mut pool: &mut impl GetConn, form: &Self::Form) -> Result<usize, Error>
|
||||
async fn leave(pool: &DbPool, form: &Self::Form) -> Result<usize, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
}
|
||||
|
@ -65,11 +61,11 @@ pub trait Joinable {
|
|||
pub trait Likeable {
|
||||
type Form;
|
||||
type IdType;
|
||||
async fn like(mut pool: &mut impl GetConn, form: &Self::Form) -> Result<Self, Error>
|
||||
async fn like(pool: &DbPool, form: &Self::Form) -> Result<Self, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
async fn remove(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
person_id: PersonId,
|
||||
item_id: Self::IdType,
|
||||
) -> Result<usize, Error>
|
||||
|
@ -80,10 +76,10 @@ pub trait Likeable {
|
|||
#[async_trait]
|
||||
pub trait Bannable {
|
||||
type Form;
|
||||
async fn ban(mut pool: &mut impl GetConn, form: &Self::Form) -> Result<Self, Error>
|
||||
async fn ban(pool: &DbPool, form: &Self::Form) -> Result<Self, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
async fn unban(mut pool: &mut impl GetConn, form: &Self::Form) -> Result<usize, Error>
|
||||
async fn unban(pool: &DbPool, form: &Self::Form) -> Result<usize, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
}
|
||||
|
@ -91,10 +87,10 @@ pub trait Bannable {
|
|||
#[async_trait]
|
||||
pub trait Saveable {
|
||||
type Form;
|
||||
async fn save(mut pool: &mut impl GetConn, form: &Self::Form) -> Result<Self, Error>
|
||||
async fn save(pool: &DbPool, form: &Self::Form) -> Result<Self, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
async fn unsave(mut pool: &mut impl GetConn, form: &Self::Form) -> Result<usize, Error>
|
||||
async fn unsave(pool: &DbPool, form: &Self::Form) -> Result<usize, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
}
|
||||
|
@ -102,10 +98,10 @@ pub trait Saveable {
|
|||
#[async_trait]
|
||||
pub trait Blockable {
|
||||
type Form;
|
||||
async fn block(mut pool: &mut impl GetConn, form: &Self::Form) -> Result<Self, Error>
|
||||
async fn block(pool: &DbPool, form: &Self::Form) -> Result<Self, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
async fn unblock(mut pool: &mut impl GetConn, form: &Self::Form) -> Result<usize, Error>
|
||||
async fn unblock(pool: &DbPool, form: &Self::Form) -> Result<usize, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
}
|
||||
|
@ -113,10 +109,10 @@ pub trait Blockable {
|
|||
#[async_trait]
|
||||
pub trait Readable {
|
||||
type Form;
|
||||
async fn mark_as_read(mut pool: &mut impl GetConn, form: &Self::Form) -> Result<Self, Error>
|
||||
async fn mark_as_read(pool: &DbPool, form: &Self::Form) -> Result<Self, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
async fn mark_as_unread(mut pool: &mut impl GetConn, form: &Self::Form) -> Result<usize, Error>
|
||||
async fn mark_as_unread(pool: &DbPool, form: &Self::Form) -> Result<usize, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
}
|
||||
|
@ -125,18 +121,18 @@ pub trait Readable {
|
|||
pub trait Reportable {
|
||||
type Form;
|
||||
type IdType;
|
||||
async fn report(mut pool: &mut impl GetConn, form: &Self::Form) -> Result<Self, Error>
|
||||
async fn report(pool: &DbPool, form: &Self::Form) -> Result<Self, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
async fn resolve(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
report_id: Self::IdType,
|
||||
resolver_id: PersonId,
|
||||
) -> Result<usize, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
async fn unresolve(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
report_id: Self::IdType,
|
||||
resolver_id: PersonId,
|
||||
) -> Result<usize, Error>
|
||||
|
@ -153,23 +149,20 @@ pub trait JoinView {
|
|||
|
||||
#[async_trait]
|
||||
pub trait ApubActor {
|
||||
async fn read_from_apub_id(
|
||||
mut pool: &mut impl GetConn,
|
||||
object_id: &DbUrl,
|
||||
) -> Result<Option<Self>, Error>
|
||||
async fn read_from_apub_id(pool: &DbPool, object_id: &DbUrl) -> Result<Option<Self>, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
/// - actor_name is the name of the community or user to read.
|
||||
/// - include_deleted, if true, will return communities or users that were deleted/removed
|
||||
async fn read_from_name(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
actor_name: &str,
|
||||
include_deleted: bool,
|
||||
) -> Result<Self, Error>
|
||||
where
|
||||
Self: Sized;
|
||||
async fn read_from_name_and_domain(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
actor_name: &str,
|
||||
protocol_domain: &str,
|
||||
) -> Result<Self, Error>
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
SortType,
|
||||
};
|
||||
use activitypub_federation::{fetch::object_id::ObjectId, traits::Object};
|
||||
use async_trait::async_trait;
|
||||
use chrono::NaiveDateTime;
|
||||
use deadpool::Runtime;
|
||||
use diesel::{
|
||||
|
@ -49,50 +48,10 @@ const POOL_TIMEOUT: Option<Duration> = Some(Duration::from_secs(5));
|
|||
|
||||
pub type DbPool = Pool<AsyncPgConnection>;
|
||||
|
||||
#[async_trait]
|
||||
pub trait GetConn: Send {
|
||||
type Conn<'conn>: std::ops::DerefMut<Target = AsyncPgConnection> + Send
|
||||
where
|
||||
Self: 'conn;
|
||||
|
||||
// Without `&mut`, `self` would move when this method is called,
|
||||
// which prevents calling it multiple times on the same `impl GetConn`.
|
||||
async fn get_conn<'conn>(&mut self) -> Result<Self::Conn<'conn>, DieselError>
|
||||
where
|
||||
'life0: 'conn; //where
|
||||
//Self::Conn: 'life0;
|
||||
pub async fn get_conn(pool: &DbPool) -> Result<PooledConnection<AsyncPgConnection>, DieselError> {
|
||||
pool.get().await.map_err(|e| QueryBuilderError(e.into()))
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<'a> GetConn for &'a DbPool {
|
||||
type Conn<'conn> = PooledConnection<AsyncPgConnection> where Self: 'conn;
|
||||
|
||||
async fn get_conn<'conn>(&mut self) -> Result<Self::Conn<'conn>, DieselError>
|
||||
where
|
||||
'life0: 'conn, //where
|
||||
//Self::Conn: 'life0,
|
||||
{
|
||||
self.get().await.map_err(|e| QueryBuilderError(e.into()))
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl GetConn for AsyncPgConnection {
|
||||
type Conn<'conn> = &'conn mut AsyncPgConnection where Self: 'conn;
|
||||
|
||||
async fn get_conn<'conn>(&mut self) -> Result<Self::Conn<'conn>, DieselError>
|
||||
where
|
||||
'life0: 'conn, //where
|
||||
//Self::Conn: 'life0,
|
||||
{
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
|
||||
/*pub async fn get_conn<T: GetConn>(getter: T) -> Result<T::Conn, DieselError> {
|
||||
getter.get_conn().await
|
||||
}*/
|
||||
|
||||
pub fn get_database_url_from_env() -> Result<String, VarError> {
|
||||
env::var("LEMMY_DATABASE_URL")
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ use lemmy_db_schema::{
|
|||
post::Post,
|
||||
},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
};
|
||||
use typed_builder::TypedBuilder;
|
||||
|
||||
|
@ -40,11 +40,11 @@ impl CommentReportView {
|
|||
///
|
||||
/// * `report_id` - the report id to obtain
|
||||
pub async fn read(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
report_id: CommentReportId,
|
||||
my_person_id: PersonId,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
let (person_alias_1, person_alias_2) = diesel::alias!(person as person1, person as person2);
|
||||
|
||||
|
@ -96,14 +96,14 @@ impl CommentReportView {
|
|||
|
||||
/// Returns the current unresolved post report count for the communities you mod
|
||||
pub async fn get_report_count(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
my_person_id: PersonId,
|
||||
admin: bool,
|
||||
community_id: Option<CommunityId>,
|
||||
) -> Result<i64, Error> {
|
||||
use diesel::dsl::count;
|
||||
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
let mut query = comment_report::table
|
||||
.inner_join(comment::table)
|
||||
|
|
|
@ -36,7 +36,7 @@ use lemmy_db_schema::{
|
|||
post::Post,
|
||||
},
|
||||
traits::JoinView,
|
||||
utils::{fuzzy_search, limit_and_offset, DbPool, GetConn},
|
||||
utils::{fuzzy_search, get_conn, limit_and_offset, DbPool},
|
||||
CommentSortType,
|
||||
ListingType,
|
||||
};
|
||||
|
@ -57,11 +57,11 @@ type CommentViewTuple = (
|
|||
|
||||
impl CommentView {
|
||||
pub async fn read(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
comment_id: CommentId,
|
||||
my_person_id: Option<PersonId>,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
// The left join below will return None in this case
|
||||
let person_id_join = my_person_id.unwrap_or(PersonId(-1));
|
||||
|
@ -431,7 +431,7 @@ mod tests {
|
|||
inserted_community: Community,
|
||||
}
|
||||
|
||||
async fn init_data(mut pool: &mut impl GetConn) -> Data {
|
||||
async fn init_data(pool: &DbPool) -> Data {
|
||||
let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string())
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -781,7 +781,7 @@ mod tests {
|
|||
cleanup(data, pool).await;
|
||||
}
|
||||
|
||||
async fn cleanup(data: Data, mut pool: &mut impl GetConn) {
|
||||
async fn cleanup(data: Data, pool: &DbPool) {
|
||||
CommentLike::remove(pool, data.inserted_person.id, data.inserted_comment_0.id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -804,7 +804,7 @@ mod tests {
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
async fn expected_comment_view(data: &Data, mut pool: &mut impl GetConn) -> CommentView {
|
||||
async fn expected_comment_view(data: &Data, pool: &DbPool) -> CommentView {
|
||||
let agg = CommentAggregates::read(pool, data.inserted_comment_0.id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
|
|
@ -5,15 +5,15 @@ use lemmy_db_schema::{
|
|||
newtypes::{CustomEmojiId, LocalSiteId},
|
||||
schema::{custom_emoji, custom_emoji_keyword},
|
||||
source::{custom_emoji::CustomEmoji, custom_emoji_keyword::CustomEmojiKeyword},
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
type CustomEmojiTuple = (CustomEmoji, Option<CustomEmojiKeyword>);
|
||||
|
||||
impl CustomEmojiView {
|
||||
pub async fn get(mut pool: &mut impl GetConn, emoji_id: CustomEmojiId) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn get(pool: &DbPool, emoji_id: CustomEmojiId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let emojis = custom_emoji::table
|
||||
.find(emoji_id)
|
||||
.left_join(
|
||||
|
@ -35,11 +35,8 @@ impl CustomEmojiView {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn get_all(
|
||||
mut pool: &mut impl GetConn,
|
||||
for_local_site_id: LocalSiteId,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn get_all(pool: &DbPool, for_local_site_id: LocalSiteId) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let emojis = custom_emoji::table
|
||||
.filter(custom_emoji::local_site_id.eq(for_local_site_id))
|
||||
.left_join(
|
||||
|
|
|
@ -7,17 +7,14 @@ use lemmy_db_schema::{
|
|||
schema::{local_user, person, person_aggregates},
|
||||
source::{local_user::LocalUser, person::Person},
|
||||
traits::JoinView,
|
||||
utils::{functions::lower, DbPool, GetConn},
|
||||
utils::{functions::lower, get_conn, DbPool},
|
||||
};
|
||||
|
||||
type LocalUserViewTuple = (LocalUser, Person, PersonAggregates);
|
||||
|
||||
impl LocalUserView {
|
||||
pub async fn read(
|
||||
mut pool: &mut impl GetConn,
|
||||
local_user_id: LocalUserId,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read(pool: &DbPool, local_user_id: LocalUserId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
let (local_user, person, counts) = local_user::table
|
||||
.find(local_user_id)
|
||||
|
@ -37,11 +34,8 @@ impl LocalUserView {
|
|||
})
|
||||
}
|
||||
|
||||
pub async fn read_person(
|
||||
mut pool: &mut impl GetConn,
|
||||
person_id: PersonId,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read_person(pool: &DbPool, person_id: PersonId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let (local_user, person, counts) = local_user::table
|
||||
.filter(person::id.eq(person_id))
|
||||
.inner_join(person::table)
|
||||
|
@ -60,8 +54,8 @@ impl LocalUserView {
|
|||
})
|
||||
}
|
||||
|
||||
pub async fn read_from_name(mut pool: &mut impl GetConn, name: &str) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read_from_name(pool: &DbPool, name: &str) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let (local_user, person, counts) = local_user::table
|
||||
.filter(lower(person::name).eq(name.to_lowercase()))
|
||||
.inner_join(person::table)
|
||||
|
@ -80,11 +74,8 @@ impl LocalUserView {
|
|||
})
|
||||
}
|
||||
|
||||
pub async fn find_by_email_or_name(
|
||||
mut pool: &mut impl GetConn,
|
||||
name_or_email: &str,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn find_by_email_or_name(pool: &DbPool, name_or_email: &str) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let (local_user, person, counts) = local_user::table
|
||||
.inner_join(person::table)
|
||||
.inner_join(person_aggregates::table.on(person::id.eq(person_aggregates::person_id)))
|
||||
|
@ -107,8 +98,8 @@ impl LocalUserView {
|
|||
})
|
||||
}
|
||||
|
||||
pub async fn find_by_email(mut pool: &mut impl GetConn, from_email: &str) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn find_by_email(pool: &DbPool, from_email: &str) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let (local_user, person, counts) = local_user::table
|
||||
.inner_join(person::table)
|
||||
.inner_join(person_aggregates::table.on(person::id.eq(person_aggregates::person_id)))
|
||||
|
@ -127,8 +118,8 @@ impl LocalUserView {
|
|||
})
|
||||
}
|
||||
|
||||
pub async fn list_admins_with_emails(mut pool: &mut impl GetConn) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn list_admins_with_emails(pool: &DbPool) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let res = local_user::table
|
||||
.filter(person::admin.eq(true))
|
||||
.filter(local_user::email.is_not_null())
|
||||
|
|
|
@ -28,7 +28,7 @@ use lemmy_db_schema::{
|
|||
post_report::PostReport,
|
||||
},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
};
|
||||
use typed_builder::TypedBuilder;
|
||||
|
||||
|
@ -49,11 +49,11 @@ impl PostReportView {
|
|||
///
|
||||
/// * `report_id` - the report id to obtain
|
||||
pub async fn read(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
report_id: PostReportId,
|
||||
my_person_id: PersonId,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let (person_alias_1, person_alias_2) = diesel::alias!(person as person1, person as person2);
|
||||
|
||||
let (
|
||||
|
@ -121,13 +121,13 @@ impl PostReportView {
|
|||
|
||||
/// returns the current unresolved post report count for the communities you mod
|
||||
pub async fn get_report_count(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
my_person_id: PersonId,
|
||||
admin: bool,
|
||||
community_id: Option<CommunityId>,
|
||||
) -> Result<i64, Error> {
|
||||
use diesel::dsl::count;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let mut query = post_report::table
|
||||
.inner_join(post::table)
|
||||
.filter(post_report::resolved.eq(false))
|
||||
|
|
|
@ -40,7 +40,7 @@ use lemmy_db_schema::{
|
|||
post::{Post, PostRead, PostSaved},
|
||||
},
|
||||
traits::JoinView,
|
||||
utils::{fuzzy_search, limit_and_offset, DbPool, GetConn},
|
||||
utils::{fuzzy_search, get_conn, limit_and_offset, DbPool},
|
||||
ListingType,
|
||||
SortType,
|
||||
};
|
||||
|
@ -65,12 +65,12 @@ sql_function!(fn coalesce(x: sql_types::Nullable<sql_types::BigInt>, y: sql_type
|
|||
|
||||
impl PostView {
|
||||
pub async fn read(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
post_id: PostId,
|
||||
my_person_id: Option<PersonId>,
|
||||
is_mod_or_admin: Option<bool>,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
// The left join below will return None in this case
|
||||
let person_id_join = my_person_id.unwrap_or(PersonId(-1));
|
||||
|
@ -510,7 +510,7 @@ mod tests {
|
|||
inserted_post: Post,
|
||||
}
|
||||
|
||||
async fn init_data(mut pool: &mut impl GetConn) -> Data {
|
||||
async fn init_data(pool: &DbPool) -> Data {
|
||||
let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string())
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -930,7 +930,7 @@ mod tests {
|
|||
cleanup(data, pool).await;
|
||||
}
|
||||
|
||||
async fn cleanup(data: Data, mut pool: &mut impl GetConn) {
|
||||
async fn cleanup(data: Data, pool: &DbPool) {
|
||||
let num_deleted = Post::delete(pool, data.inserted_post.id).await.unwrap();
|
||||
Community::delete(pool, data.inserted_community.id)
|
||||
.await
|
||||
|
@ -946,7 +946,7 @@ mod tests {
|
|||
assert_eq!(1, num_deleted);
|
||||
}
|
||||
|
||||
async fn expected_post_view(data: &Data, mut pool: &mut impl GetConn) -> PostView {
|
||||
async fn expected_post_view(data: &Data, pool: &DbPool) -> PostView {
|
||||
let (inserted_person, inserted_community, inserted_post) = (
|
||||
&data.inserted_person,
|
||||
&data.inserted_community,
|
||||
|
|
|
@ -10,7 +10,7 @@ use lemmy_db_schema::{
|
|||
private_message_report::PrivateMessageReport,
|
||||
},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
};
|
||||
use typed_builder::TypedBuilder;
|
||||
|
||||
|
@ -26,11 +26,8 @@ impl PrivateMessageReportView {
|
|||
/// returns the PrivateMessageReportView for the provided report_id
|
||||
///
|
||||
/// * `report_id` - the report id to obtain
|
||||
pub async fn read(
|
||||
mut pool: &mut impl GetConn,
|
||||
report_id: PrivateMessageReportId,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read(pool: &DbPool, report_id: PrivateMessageReportId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let (person_alias_1, person_alias_2) = diesel::alias!(person as person1, person as person2);
|
||||
|
||||
let (private_message_report, private_message, private_message_creator, creator, resolver) =
|
||||
|
@ -67,9 +64,9 @@ impl PrivateMessageReportView {
|
|||
}
|
||||
|
||||
/// Returns the current unresolved post report count for the communities you mod
|
||||
pub async fn get_report_count(mut pool: &mut impl GetConn) -> Result<i64, Error> {
|
||||
pub async fn get_report_count(pool: &DbPool) -> Result<i64, Error> {
|
||||
use diesel::dsl::count;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
private_message_report::table
|
||||
.inner_join(private_message::table)
|
||||
|
|
|
@ -14,7 +14,7 @@ use lemmy_db_schema::{
|
|||
schema::{person, private_message},
|
||||
source::{person::Person, private_message::PrivateMessage},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
};
|
||||
use tracing::debug;
|
||||
use typed_builder::TypedBuilder;
|
||||
|
@ -22,11 +22,8 @@ use typed_builder::TypedBuilder;
|
|||
type PrivateMessageViewTuple = (PrivateMessage, Person, Person);
|
||||
|
||||
impl PrivateMessageView {
|
||||
pub async fn read(
|
||||
mut pool: &mut impl GetConn,
|
||||
private_message_id: PrivateMessageId,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read(pool: &DbPool, private_message_id: PrivateMessageId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let person_alias_1 = diesel::alias!(person as person1);
|
||||
|
||||
let (private_message, creator, recipient) = private_message::table
|
||||
|
@ -52,12 +49,9 @@ impl PrivateMessageView {
|
|||
}
|
||||
|
||||
/// Gets the number of unread messages
|
||||
pub async fn get_unread_messages(
|
||||
mut pool: &mut impl GetConn,
|
||||
my_person_id: PersonId,
|
||||
) -> Result<i64, Error> {
|
||||
pub async fn get_unread_messages(pool: &DbPool, my_person_id: PersonId) -> Result<i64, Error> {
|
||||
use diesel::dsl::count;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
private_message::table
|
||||
.filter(private_message::read.eq(false))
|
||||
.filter(private_message::recipient_id.eq(my_person_id))
|
||||
|
|
|
@ -16,7 +16,7 @@ use lemmy_db_schema::{
|
|||
registration_application::RegistrationApplication,
|
||||
},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
};
|
||||
use typed_builder::TypedBuilder;
|
||||
|
||||
|
@ -24,11 +24,8 @@ type RegistrationApplicationViewTuple =
|
|||
(RegistrationApplication, LocalUser, Person, Option<Person>);
|
||||
|
||||
impl RegistrationApplicationView {
|
||||
pub async fn read(
|
||||
mut pool: &mut impl GetConn,
|
||||
registration_application_id: i32,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read(pool: &DbPool, registration_application_id: i32) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let person_alias_1 = diesel::alias!(person as person1);
|
||||
|
||||
let (registration_application, creator_local_user, creator, admin) =
|
||||
|
@ -61,11 +58,8 @@ impl RegistrationApplicationView {
|
|||
}
|
||||
|
||||
/// Returns the current unread registration_application count
|
||||
pub async fn get_unread_count(
|
||||
mut pool: &mut impl GetConn,
|
||||
verified_email_only: bool,
|
||||
) -> Result<i64, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn get_unread_count(pool: &DbPool, verified_email_only: bool) -> Result<i64, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let person_alias_1 = diesel::alias!(person as person1);
|
||||
|
||||
let mut query = registration_application::table
|
||||
|
|
|
@ -5,12 +5,12 @@ use lemmy_db_schema::{
|
|||
aggregates::structs::SiteAggregates,
|
||||
schema::{local_site, local_site_rate_limit, site, site_aggregates},
|
||||
source::{local_site::LocalSite, local_site_rate_limit::LocalSiteRateLimit, site::Site},
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
|
||||
impl SiteView {
|
||||
pub async fn read_local(mut pool: &mut impl GetConn) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read_local(pool: &DbPool) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let (mut site, local_site, local_site_rate_limit, counts) = site::table
|
||||
.inner_join(local_site::table)
|
||||
.inner_join(
|
||||
|
|
|
@ -33,7 +33,7 @@ use lemmy_db_schema::{
|
|||
post::Post,
|
||||
},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
CommentSortType,
|
||||
};
|
||||
use typed_builder::TypedBuilder;
|
||||
|
@ -55,11 +55,11 @@ type CommentReplyViewTuple = (
|
|||
|
||||
impl CommentReplyView {
|
||||
pub async fn read(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
comment_reply_id: CommentReplyId,
|
||||
my_person_id: Option<PersonId>,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let person_alias_1 = diesel::alias!(person as person1);
|
||||
|
||||
// The left join below will return None in this case
|
||||
|
@ -155,13 +155,10 @@ impl CommentReplyView {
|
|||
}
|
||||
|
||||
/// Gets the number of unread replies
|
||||
pub async fn get_unread_replies(
|
||||
mut pool: &mut impl GetConn,
|
||||
my_person_id: PersonId,
|
||||
) -> Result<i64, Error> {
|
||||
pub async fn get_unread_replies(pool: &DbPool, my_person_id: PersonId) -> Result<i64, Error> {
|
||||
use diesel::dsl::count;
|
||||
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
comment_reply::table
|
||||
.inner_join(comment::table)
|
||||
|
|
|
@ -6,17 +6,14 @@ use lemmy_db_schema::{
|
|||
schema::{community, community_block, person},
|
||||
source::{community::Community, person::Person},
|
||||
traits::JoinView,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
|
||||
type CommunityBlockViewTuple = (Person, Community);
|
||||
|
||||
impl CommunityBlockView {
|
||||
pub async fn for_person(
|
||||
mut pool: &mut impl GetConn,
|
||||
person_id: PersonId,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn for_person(pool: &DbPool, person_id: PersonId) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let res = community_block::table
|
||||
.inner_join(person::table)
|
||||
.inner_join(community::table)
|
||||
|
|
|
@ -6,17 +6,14 @@ use lemmy_db_schema::{
|
|||
schema::{community, community_follower, person},
|
||||
source::{community::Community, person::Person},
|
||||
traits::JoinView,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
|
||||
type CommunityFollowerViewTuple = (Community, Person);
|
||||
|
||||
impl CommunityFollowerView {
|
||||
pub async fn for_community(
|
||||
mut pool: &mut impl GetConn,
|
||||
community_id: CommunityId,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn for_community(pool: &DbPool, community_id: CommunityId) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let res = community_follower::table
|
||||
.inner_join(community::table)
|
||||
.inner_join(person::table)
|
||||
|
@ -29,11 +26,8 @@ impl CommunityFollowerView {
|
|||
Ok(res.into_iter().map(Self::from_tuple).collect())
|
||||
}
|
||||
|
||||
pub async fn for_person(
|
||||
mut pool: &mut impl GetConn,
|
||||
person_id: PersonId,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn for_person(pool: &DbPool, person_id: PersonId) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let res = community_follower::table
|
||||
.inner_join(community::table)
|
||||
.inner_join(person::table)
|
||||
|
|
|
@ -6,17 +6,14 @@ use lemmy_db_schema::{
|
|||
schema::{community, community_moderator, person},
|
||||
source::{community::Community, person::Person},
|
||||
traits::JoinView,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
|
||||
type CommunityModeratorViewTuple = (Community, Person);
|
||||
|
||||
impl CommunityModeratorView {
|
||||
pub async fn for_community(
|
||||
mut pool: &mut impl GetConn,
|
||||
community_id: CommunityId,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn for_community(pool: &DbPool, community_id: CommunityId) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let res = community_moderator::table
|
||||
.inner_join(community::table)
|
||||
.inner_join(person::table)
|
||||
|
@ -28,11 +25,8 @@ impl CommunityModeratorView {
|
|||
Ok(res.into_iter().map(Self::from_tuple).collect())
|
||||
}
|
||||
|
||||
pub async fn for_person(
|
||||
mut pool: &mut impl GetConn,
|
||||
person_id: PersonId,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn for_person(pool: &DbPool, person_id: PersonId) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let res = community_moderator::table
|
||||
.inner_join(community::table)
|
||||
.inner_join(person::table)
|
||||
|
@ -48,8 +42,8 @@ impl CommunityModeratorView {
|
|||
|
||||
/// Finds all communities first mods / creators
|
||||
/// Ideally this should be a group by, but diesel doesn't support it yet
|
||||
pub async fn get_community_first_mods(mut pool: &mut impl GetConn) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn get_community_first_mods(pool: &DbPool) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let res = community_moderator::table
|
||||
.inner_join(community::table)
|
||||
.inner_join(person::table)
|
||||
|
|
|
@ -5,16 +5,16 @@ use lemmy_db_schema::{
|
|||
newtypes::{CommunityId, PersonId},
|
||||
schema::{community, community_person_ban, person},
|
||||
source::{community::Community, person::Person},
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
|
||||
impl CommunityPersonBanView {
|
||||
pub async fn get(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
from_person_id: PersonId,
|
||||
from_community_id: CommunityId,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let (community, person) = community_person_ban::table
|
||||
.inner_join(community::table)
|
||||
.inner_join(person::table)
|
||||
|
|
|
@ -19,7 +19,7 @@ use lemmy_db_schema::{
|
|||
local_user::LocalUser,
|
||||
},
|
||||
traits::JoinView,
|
||||
utils::{fuzzy_search, limit_and_offset, DbPool, GetConn},
|
||||
utils::{fuzzy_search, get_conn, limit_and_offset, DbPool},
|
||||
ListingType,
|
||||
SortType,
|
||||
};
|
||||
|
@ -34,12 +34,12 @@ type CommunityViewTuple = (
|
|||
|
||||
impl CommunityView {
|
||||
pub async fn read(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
community_id: CommunityId,
|
||||
my_person_id: Option<PersonId>,
|
||||
is_mod_or_admin: Option<bool>,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
// The left join below will return None in this case
|
||||
let person_id_join = my_person_id.unwrap_or(PersonId(-1));
|
||||
|
||||
|
@ -86,7 +86,7 @@ impl CommunityView {
|
|||
}
|
||||
|
||||
pub async fn is_mod_or_admin(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
person_id: PersonId,
|
||||
community_id: CommunityId,
|
||||
) -> Result<bool, Error> {
|
||||
|
|
|
@ -6,17 +6,14 @@ use lemmy_db_schema::{
|
|||
schema::{person, person_block},
|
||||
source::person::Person,
|
||||
traits::JoinView,
|
||||
utils::{DbPool, GetConn},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
|
||||
type PersonBlockViewTuple = (Person, Person);
|
||||
|
||||
impl PersonBlockView {
|
||||
pub async fn for_person(
|
||||
mut pool: &mut impl GetConn,
|
||||
person_id: PersonId,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn for_person(pool: &DbPool, person_id: PersonId) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let target_person_alias = diesel::alias!(person as person1);
|
||||
|
||||
let res = person_block::table
|
||||
|
|
|
@ -34,7 +34,7 @@ use lemmy_db_schema::{
|
|||
post::Post,
|
||||
},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
CommentSortType,
|
||||
};
|
||||
use typed_builder::TypedBuilder;
|
||||
|
@ -56,11 +56,11 @@ type PersonMentionViewTuple = (
|
|||
|
||||
impl PersonMentionView {
|
||||
pub async fn read(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
person_mention_id: PersonMentionId,
|
||||
my_person_id: Option<PersonId>,
|
||||
) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let person_alias_1 = diesel::alias!(person as person1);
|
||||
|
||||
// The left join below will return None in this case
|
||||
|
@ -156,12 +156,9 @@ impl PersonMentionView {
|
|||
}
|
||||
|
||||
/// Gets the number of unread mentions
|
||||
pub async fn get_unread_mentions(
|
||||
mut pool: &mut impl GetConn,
|
||||
my_person_id: PersonId,
|
||||
) -> Result<i64, Error> {
|
||||
pub async fn get_unread_mentions(pool: &DbPool, my_person_id: PersonId) -> Result<i64, Error> {
|
||||
use diesel::dsl::count;
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
person_mention::table
|
||||
.inner_join(comment::table)
|
||||
|
|
|
@ -14,7 +14,7 @@ use lemmy_db_schema::{
|
|||
schema::{person, person_aggregates},
|
||||
source::person::Person,
|
||||
traits::JoinView,
|
||||
utils::{fuzzy_search, limit_and_offset, DbPool, GetConn},
|
||||
utils::{fuzzy_search, get_conn, limit_and_offset, DbPool},
|
||||
SortType,
|
||||
};
|
||||
use std::iter::Iterator;
|
||||
|
@ -23,8 +23,8 @@ use typed_builder::TypedBuilder;
|
|||
type PersonViewTuple = (Person, PersonAggregates);
|
||||
|
||||
impl PersonView {
|
||||
pub async fn read(mut pool: &mut impl GetConn, person_id: PersonId) -> Result<Self, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn read(pool: &DbPool, person_id: PersonId) -> Result<Self, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let res = person::table
|
||||
.find(person_id)
|
||||
.inner_join(person_aggregates::table)
|
||||
|
@ -34,8 +34,8 @@ impl PersonView {
|
|||
Ok(Self::from_tuple(res))
|
||||
}
|
||||
|
||||
pub async fn admins(mut pool: &mut impl GetConn) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn admins(pool: &DbPool) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let admins = person::table
|
||||
.inner_join(person_aggregates::table)
|
||||
.select((person::all_columns, person_aggregates::all_columns))
|
||||
|
@ -48,8 +48,8 @@ impl PersonView {
|
|||
Ok(admins.into_iter().map(Self::from_tuple).collect())
|
||||
}
|
||||
|
||||
pub async fn banned(mut pool: &mut impl GetConn) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn banned(pool: &DbPool) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let banned = person::table
|
||||
.inner_join(person_aggregates::table)
|
||||
.select((person::all_columns, person_aggregates::all_columns))
|
||||
|
|
|
@ -14,17 +14,14 @@ use lemmy_db_schema::{
|
|||
schema::{admin_purge_comment, person, post},
|
||||
source::{moderator::AdminPurgeComment, person::Person, post::Post},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
};
|
||||
|
||||
type AdminPurgeCommentViewTuple = (AdminPurgeComment, Option<Person>, Post);
|
||||
|
||||
impl AdminPurgeCommentView {
|
||||
pub async fn list(
|
||||
mut pool: &mut impl GetConn,
|
||||
params: ModlogListParams,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn list(pool: &DbPool, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||
|
|
|
@ -14,17 +14,14 @@ use lemmy_db_schema::{
|
|||
schema::{admin_purge_community, person},
|
||||
source::{moderator::AdminPurgeCommunity, person::Person},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
};
|
||||
|
||||
type AdminPurgeCommunityViewTuple = (AdminPurgeCommunity, Option<Person>);
|
||||
|
||||
impl AdminPurgeCommunityView {
|
||||
pub async fn list(
|
||||
mut pool: &mut impl GetConn,
|
||||
params: ModlogListParams,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn list(pool: &DbPool, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||
|
|
|
@ -14,17 +14,14 @@ use lemmy_db_schema::{
|
|||
schema::{admin_purge_person, person},
|
||||
source::{moderator::AdminPurgePerson, person::Person},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
};
|
||||
|
||||
type AdminPurgePersonViewTuple = (AdminPurgePerson, Option<Person>);
|
||||
|
||||
impl AdminPurgePersonView {
|
||||
pub async fn list(
|
||||
mut pool: &mut impl GetConn,
|
||||
params: ModlogListParams,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn list(pool: &DbPool, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
|
|
|
@ -14,17 +14,14 @@ use lemmy_db_schema::{
|
|||
schema::{admin_purge_post, community, person},
|
||||
source::{community::Community, moderator::AdminPurgePost, person::Person},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
};
|
||||
|
||||
type AdminPurgePostViewTuple = (AdminPurgePost, Option<Person>, Community);
|
||||
|
||||
impl AdminPurgePostView {
|
||||
pub async fn list(
|
||||
mut pool: &mut impl GetConn,
|
||||
params: ModlogListParams,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn list(pool: &DbPool, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
|
|
|
@ -14,17 +14,14 @@ use lemmy_db_schema::{
|
|||
schema::{community, mod_add_community, person},
|
||||
source::{community::Community, moderator::ModAddCommunity, person::Person},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
};
|
||||
|
||||
type ModAddCommunityViewTuple = (ModAddCommunity, Option<Person>, Community, Person);
|
||||
|
||||
impl ModAddCommunityView {
|
||||
pub async fn list(
|
||||
mut pool: &mut impl GetConn,
|
||||
params: ModlogListParams,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn list(pool: &DbPool, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let person_alias_1 = diesel::alias!(person as person1);
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
|
|
|
@ -14,17 +14,14 @@ use lemmy_db_schema::{
|
|||
schema::{mod_add, person},
|
||||
source::{moderator::ModAdd, person::Person},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
};
|
||||
|
||||
type ModAddViewTuple = (ModAdd, Option<Person>, Person);
|
||||
|
||||
impl ModAddView {
|
||||
pub async fn list(
|
||||
mut pool: &mut impl GetConn,
|
||||
params: ModlogListParams,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn list(pool: &DbPool, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let person_alias_1 = diesel::alias!(person as person1);
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
|
|
|
@ -14,17 +14,14 @@ use lemmy_db_schema::{
|
|||
schema::{community, mod_ban_from_community, person},
|
||||
source::{community::Community, moderator::ModBanFromCommunity, person::Person},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
};
|
||||
|
||||
type ModBanFromCommunityViewTuple = (ModBanFromCommunity, Option<Person>, Community, Person);
|
||||
|
||||
impl ModBanFromCommunityView {
|
||||
pub async fn list(
|
||||
mut pool: &mut impl GetConn,
|
||||
params: ModlogListParams,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn list(pool: &DbPool, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
let person_alias_1 = diesel::alias!(person as person1);
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
|
|
|
@ -14,17 +14,14 @@ use lemmy_db_schema::{
|
|||
schema::{mod_ban, person},
|
||||
source::{moderator::ModBan, person::Person},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
};
|
||||
|
||||
type ModBanViewTuple = (ModBan, Option<Person>, Person);
|
||||
|
||||
impl ModBanView {
|
||||
pub async fn list(
|
||||
mut pool: &mut impl GetConn,
|
||||
params: ModlogListParams,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn list(pool: &DbPool, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let person_alias_1 = diesel::alias!(person as person1);
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
|
|
|
@ -14,17 +14,14 @@ use lemmy_db_schema::{
|
|||
schema::{community, mod_feature_post, person, post},
|
||||
source::{community::Community, moderator::ModFeaturePost, person::Person, post::Post},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
};
|
||||
|
||||
type ModFeaturePostViewTuple = (ModFeaturePost, Option<Person>, Post, Community);
|
||||
|
||||
impl ModFeaturePostView {
|
||||
pub async fn list(
|
||||
mut pool: &mut impl GetConn,
|
||||
params: ModlogListParams,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn list(pool: &DbPool, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let person_alias_1 = diesel::alias!(person as person1);
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
|
|
|
@ -14,18 +14,15 @@ use lemmy_db_schema::{
|
|||
schema::{community, mod_hide_community, person},
|
||||
source::{community::Community, moderator::ModHideCommunity, person::Person},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
};
|
||||
|
||||
type ModHideCommunityViewTuple = (ModHideCommunity, Option<Person>, Community);
|
||||
|
||||
impl ModHideCommunityView {
|
||||
// Pass in mod_id as admin_id because only admins can do this action
|
||||
pub async fn list(
|
||||
mut pool: &mut impl GetConn,
|
||||
params: ModlogListParams,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn list(pool: &DbPool, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
|
|
|
@ -14,17 +14,14 @@ use lemmy_db_schema::{
|
|||
schema::{community, mod_lock_post, person, post},
|
||||
source::{community::Community, moderator::ModLockPost, person::Person, post::Post},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
};
|
||||
|
||||
type ModLockPostViewTuple = (ModLockPost, Option<Person>, Post, Community);
|
||||
|
||||
impl ModLockPostView {
|
||||
pub async fn list(
|
||||
mut pool: &mut impl GetConn,
|
||||
params: ModlogListParams,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn list(pool: &DbPool, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
let person_alias_1 = diesel::alias!(person as person1);
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
|
|
|
@ -20,7 +20,7 @@ use lemmy_db_schema::{
|
|||
post::Post,
|
||||
},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
};
|
||||
|
||||
type ModRemoveCommentViewTuple = (
|
||||
|
@ -33,11 +33,8 @@ type ModRemoveCommentViewTuple = (
|
|||
);
|
||||
|
||||
impl ModRemoveCommentView {
|
||||
pub async fn list(
|
||||
mut pool: &mut impl GetConn,
|
||||
params: ModlogListParams,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn list(pool: &DbPool, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let person_alias_1 = diesel::alias!(lemmy_db_schema::schema::person as person1);
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
|
|
|
@ -14,17 +14,14 @@ use lemmy_db_schema::{
|
|||
schema::{community, mod_remove_community, person},
|
||||
source::{community::Community, moderator::ModRemoveCommunity, person::Person},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
};
|
||||
|
||||
type ModRemoveCommunityTuple = (ModRemoveCommunity, Option<Person>, Community);
|
||||
|
||||
impl ModRemoveCommunityView {
|
||||
pub async fn list(
|
||||
mut pool: &mut impl GetConn,
|
||||
params: ModlogListParams,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn list(pool: &DbPool, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
let show_mod_names = !params.hide_modlog_names;
|
||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||
|
|
|
@ -14,17 +14,14 @@ use lemmy_db_schema::{
|
|||
schema::{community, mod_remove_post, person, post},
|
||||
source::{community::Community, moderator::ModRemovePost, person::Person, post::Post},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
};
|
||||
|
||||
type ModRemovePostViewTuple = (ModRemovePost, Option<Person>, Post, Community);
|
||||
|
||||
impl ModRemovePostView {
|
||||
pub async fn list(
|
||||
mut pool: &mut impl GetConn,
|
||||
params: ModlogListParams,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn list(pool: &DbPool, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
let person_alias_1 = diesel::alias!(person as person1);
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
|
|
|
@ -14,17 +14,14 @@ use lemmy_db_schema::{
|
|||
schema::{community, mod_transfer_community, person},
|
||||
source::{community::Community, moderator::ModTransferCommunity, person::Person},
|
||||
traits::JoinView,
|
||||
utils::{limit_and_offset, DbPool, GetConn},
|
||||
utils::{get_conn, limit_and_offset, DbPool},
|
||||
};
|
||||
|
||||
type ModTransferCommunityViewTuple = (ModTransferCommunity, Option<Person>, Community, Person);
|
||||
|
||||
impl ModTransferCommunityView {
|
||||
pub async fn list(
|
||||
mut pool: &mut impl GetConn,
|
||||
params: ModlogListParams,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
pub async fn list(pool: &DbPool, params: ModlogListParams) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
let person_alias_1 = diesel::alias!(person as person1);
|
||||
let admin_person_id_join = params.mod_person_id.unwrap_or(PersonId(-1));
|
||||
|
|
|
@ -6,7 +6,7 @@ use lemmy_db_schema::{
|
|||
newtypes::LocalUserId,
|
||||
source::{community::Community, local_user::LocalUser, person::Person},
|
||||
traits::{ApubActor, Crud},
|
||||
utils::{DbPool, GetConn},
|
||||
utils::DbPool,
|
||||
CommentSortType,
|
||||
ListingType,
|
||||
SortType,
|
||||
|
@ -227,7 +227,7 @@ async fn get_feed(
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn get_feed_user(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
sort_type: &SortType,
|
||||
limit: &i64,
|
||||
page: &i64,
|
||||
|
@ -262,7 +262,7 @@ async fn get_feed_user(
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn get_feed_community(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
sort_type: &SortType,
|
||||
limit: &i64,
|
||||
page: &i64,
|
||||
|
@ -300,7 +300,7 @@ async fn get_feed_community(
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn get_feed_front(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
jwt_secret: &str,
|
||||
sort_type: &SortType,
|
||||
limit: &i64,
|
||||
|
@ -341,7 +341,7 @@ async fn get_feed_front(
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn get_feed_inbox(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
jwt_secret: &str,
|
||||
jwt: &str,
|
||||
protocol_and_hostname: &str,
|
||||
|
|
|
@ -33,16 +33,13 @@ use lemmy_db_schema::{
|
|||
site::{Site, SiteInsertForm, SiteUpdateForm},
|
||||
},
|
||||
traits::Crud,
|
||||
utils::{naive_now, DbPool, GetConn},
|
||||
utils::{get_conn, naive_now, DbPool},
|
||||
};
|
||||
use lemmy_utils::{error::LemmyError, settings::structs::Settings};
|
||||
use tracing::info;
|
||||
use url::Url;
|
||||
|
||||
pub async fn run_advanced_migrations(
|
||||
mut pool: &mut impl GetConn,
|
||||
settings: &Settings,
|
||||
) -> Result<(), LemmyError> {
|
||||
pub async fn run_advanced_migrations(pool: &DbPool, settings: &Settings) -> Result<(), LemmyError> {
|
||||
let protocol_and_hostname = &settings.get_protocol_and_hostname();
|
||||
user_updates_2020_04_02(pool, protocol_and_hostname).await?;
|
||||
community_updates_2020_04_02(pool, protocol_and_hostname).await?;
|
||||
|
@ -59,11 +56,11 @@ pub async fn run_advanced_migrations(
|
|||
}
|
||||
|
||||
async fn user_updates_2020_04_02(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
protocol_and_hostname: &str,
|
||||
) -> Result<(), LemmyError> {
|
||||
use lemmy_db_schema::schema::person::dsl::{actor_id, local, person};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
info!("Running user_updates_2020_04_02");
|
||||
|
||||
|
@ -97,11 +94,11 @@ async fn user_updates_2020_04_02(
|
|||
}
|
||||
|
||||
async fn community_updates_2020_04_02(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
protocol_and_hostname: &str,
|
||||
) -> Result<(), LemmyError> {
|
||||
use lemmy_db_schema::schema::community::dsl::{actor_id, community, local};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
info!("Running community_updates_2020_04_02");
|
||||
|
||||
|
@ -136,11 +133,11 @@ async fn community_updates_2020_04_02(
|
|||
}
|
||||
|
||||
async fn post_updates_2020_04_03(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
protocol_and_hostname: &str,
|
||||
) -> Result<(), LemmyError> {
|
||||
use lemmy_db_schema::schema::post::dsl::{ap_id, local, post};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
info!("Running post_updates_2020_04_03");
|
||||
|
||||
|
@ -171,11 +168,11 @@ async fn post_updates_2020_04_03(
|
|||
}
|
||||
|
||||
async fn comment_updates_2020_04_03(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
protocol_and_hostname: &str,
|
||||
) -> Result<(), LemmyError> {
|
||||
use lemmy_db_schema::schema::comment::dsl::{ap_id, comment, local};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
info!("Running comment_updates_2020_04_03");
|
||||
|
||||
|
@ -206,11 +203,11 @@ async fn comment_updates_2020_04_03(
|
|||
}
|
||||
|
||||
async fn private_message_updates_2020_05_05(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
protocol_and_hostname: &str,
|
||||
) -> Result<(), LemmyError> {
|
||||
use lemmy_db_schema::schema::private_message::dsl::{ap_id, local, private_message};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
info!("Running private_message_updates_2020_05_05");
|
||||
|
||||
|
@ -243,11 +240,11 @@ async fn private_message_updates_2020_05_05(
|
|||
}
|
||||
|
||||
async fn post_thumbnail_url_updates_2020_07_27(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
protocol_and_hostname: &str,
|
||||
) -> Result<(), LemmyError> {
|
||||
use lemmy_db_schema::schema::post::dsl::{post, thumbnail_url};
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
info!("Running post_thumbnail_url_updates_2020_07_27");
|
||||
|
||||
|
@ -274,8 +271,8 @@ async fn post_thumbnail_url_updates_2020_07_27(
|
|||
|
||||
/// We are setting inbox and follower URLs for local and remote actors alike, because for now
|
||||
/// all federated instances are also Lemmy and use the same URL scheme.
|
||||
async fn apub_columns_2021_02_02(mut pool: &mut impl GetConn) -> Result<(), LemmyError> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn apub_columns_2021_02_02(pool: &DbPool) -> Result<(), LemmyError> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
info!("Running apub_columns_2021_02_02");
|
||||
{
|
||||
use lemmy_db_schema::schema::person::dsl::{inbox_url, person, shared_inbox_url};
|
||||
|
@ -332,7 +329,7 @@ async fn apub_columns_2021_02_02(mut pool: &mut impl GetConn) -> Result<(), Lemm
|
|||
/// Before this point, there is only a single value in the site table which refers to the local
|
||||
/// Lemmy instance, so thats all we need to update.
|
||||
async fn instance_actor_2022_01_28(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
protocol_and_hostname: &str,
|
||||
) -> Result<(), LemmyError> {
|
||||
info!("Running instance_actor_2021_09_29");
|
||||
|
@ -361,8 +358,8 @@ async fn instance_actor_2022_01_28(
|
|||
/// key field is empty, generate a new keypair. It would be possible to regenerate only the pubkey,
|
||||
/// but thats more complicated and has no benefit, as federation is already broken for these actors.
|
||||
/// https://github.com/LemmyNet/lemmy/issues/2347
|
||||
async fn regenerate_public_keys_2022_07_05(mut pool: &mut impl GetConn) -> Result<(), LemmyError> {
|
||||
let conn = &mut *pool.get_conn().await?;
|
||||
async fn regenerate_public_keys_2022_07_05(pool: &DbPool) -> Result<(), LemmyError> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
info!("Running regenerate_public_keys_2022_07_05");
|
||||
|
||||
{
|
||||
|
@ -416,7 +413,7 @@ async fn regenerate_public_keys_2022_07_05(mut pool: &mut impl GetConn) -> Resul
|
|||
/// If a site already exists, the DB migration should generate a local_site row.
|
||||
/// This will only be run for brand new sites.
|
||||
async fn initialize_local_site_2022_10_10(
|
||||
mut pool: &mut impl GetConn,
|
||||
pool: &DbPool,
|
||||
settings: &Settings,
|
||||
) -> Result<(), LemmyError> {
|
||||
info!("Running initialize_local_site_2022_10_10");
|
||||
|
|
Loading…
Reference in a new issue