Fix stuff

pull/3420/head
dull b 2023-07-01 04:11:27 +00:00
parent 0d9db43b0a
commit 0957e2b319
18 changed files with 39 additions and 54 deletions

View File

@ -29,9 +29,8 @@ impl Perform for ListCommentReports {
let page = data.page;
let limit = data.limit;
let mut conn = context.conn().await?;
let comment_reports = CommentReportQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.my_person_id(person_id)
.admin(admin)
.community_id(community_id)

View File

@ -27,9 +27,8 @@ impl Perform for GetPersonMentions {
let person_id = Some(local_user_view.person.id);
let show_bot_accounts = Some(local_user_view.local_user.show_bot_accounts);
let mut conn = context.conn().await?;
let mentions = PersonMentionQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.recipient_id(person_id)
.my_person_id(person_id)
.sort(sort)

View File

@ -24,9 +24,8 @@ impl Perform for GetReplies {
let person_id = Some(local_user_view.person.id);
let show_bot_accounts = Some(local_user_view.local_user.show_bot_accounts);
let mut conn = context.conn().await?;
let replies = CommentReplyQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.recipient_id(person_id)
.my_person_id(person_id)
.sort(sort)

View File

@ -29,9 +29,8 @@ impl Perform for ListPostReports {
let page = data.page;
let limit = data.limit;
let mut conn = context.conn().await?;
let post_reports = PostReportQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.my_person_id(person_id)
.admin(admin)
.community_id(community_id)

View File

@ -21,9 +21,8 @@ impl Perform for ListPrivateMessageReports {
let unresolved_only = self.unresolved_only;
let page = self.page;
let limit = self.limit;
let mut conn = context.conn().await?;
let private_message_reports = PrivateMessageReportQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.unresolved_only(unresolved_only)
.page(page)
.limit(limit)

View File

@ -27,9 +27,8 @@ impl Perform for ListRegistrationApplications {
let page = data.page;
let limit = data.limit;
let mut conn = context.conn().await?;
let registration_applications = RegistrationApplicationQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.unread_only(unread_only)
.verified_email_only(Some(verified_email_only))
.page(page)

View File

@ -31,9 +31,8 @@ impl PerformCrud for ListCommunities {
let page = data.page;
let limit = data.limit;
let local_user = local_user_view.map(|l| l.local_user);
let mut conn = context.conn().await?;
let communities = CommunityQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.listing_type(listing_type)
.show_nsfw(show_nsfw)
.sort(sort)

View File

@ -54,9 +54,8 @@ impl PerformApub for GetComments {
let parent_path_cloned = parent_path.clone();
let post_id = data.post_id;
let local_user = local_user_view.map(|l| l.local_user);
let mut conn = context.conn().await?;
let comments = CommentQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.listing_type(Some(listing_type))
.sort(sort)
.max_depth(max_depth)

View File

@ -49,9 +49,8 @@ impl PerformApub for GetPosts {
.await
.is_ok();
let mut conn = context.conn().await?;
let posts = PostQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.local_user(local_user_view.map(|l| l.local_user).as_ref())
.listing_type(Some(listing_type))
.sort(sort)

View File

@ -63,9 +63,8 @@ impl PerformApub for GetPersonDetails {
let local_user = local_user_view.map(|l| l.local_user);
let local_user_clone = local_user.clone();
let mut conn = context.conn().await?;
let posts_query = PostQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.sort(sort)
.saved_only(saved_only)
.local_user(local_user.as_ref())
@ -86,9 +85,8 @@ impl PerformApub for GetPersonDetails {
}
.await?;
let mut conn = context.conn().await?;
let comments_query = CommentQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.local_user(local_user_clone.as_ref())
.sort(sort.map(post_to_comment_sort_type))
.saved_only(saved_only)

View File

@ -56,11 +56,10 @@ impl PerformApub for Search {
};
let creator_id = data.creator_id;
let local_user = local_user_view.map(|l| l.local_user);
let mut conn = context.conn().await?;
match search_type {
SearchType::Posts => {
posts = PostQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.sort(sort)
.listing_type(listing_type)
.community_id(community_id)
@ -76,7 +75,7 @@ impl PerformApub for Search {
}
SearchType::Comments => {
comments = CommentQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.sort(sort.map(post_to_comment_sort_type))
.listing_type(listing_type)
.search_term(Some(q))
@ -91,7 +90,7 @@ impl PerformApub for Search {
}
SearchType::Communities => {
communities = CommunityQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.sort(sort)
.listing_type(listing_type)
.search_term(Some(q))
@ -105,7 +104,7 @@ impl PerformApub for Search {
}
SearchType::Users => {
users = PersonQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.sort(sort)
.search_term(Some(q))
.page(page)
@ -121,7 +120,7 @@ impl PerformApub for Search {
let local_user_ = local_user.clone();
posts = PostQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.sort(sort)
.listing_type(listing_type)
.community_id(community_id)
@ -139,7 +138,7 @@ impl PerformApub for Search {
let local_user_ = local_user.clone();
comments = CommentQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.sort(sort.map(post_to_comment_sort_type))
.listing_type(listing_type)
.search_term(Some(q))
@ -158,7 +157,7 @@ impl PerformApub for Search {
vec![]
} else {
CommunityQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.sort(sort)
.listing_type(listing_type)
.search_term(Some(q))
@ -177,7 +176,7 @@ impl PerformApub for Search {
vec![]
} else {
PersonQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.sort(sort)
.search_term(Some(q))
.page(page)
@ -189,7 +188,7 @@ impl PerformApub for Search {
}
SearchType::Url => {
posts = PostQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.sort(sort)
.listing_type(listing_type)
.community_id(community_id)

View File

@ -29,7 +29,7 @@ impl Collection for ApubCommunityFeatured {
data: &Data<Self::DataType>,
) -> Result<Self::Kind, Self::Error> {
let ordered_items = try_join_all(
Post::list_featured_for_community(&mut *data.conn().await?, owner.id)
Post::list_featured_for_community(data.conn().await?, owner.id)
.await?
.into_iter()
.map(ApubPost::from)

View File

@ -33,8 +33,7 @@ impl Collection for ApubCommunityModerators {
owner: &Self::Owner,
data: &Data<Self::DataType>,
) -> Result<Self::Kind, LemmyError> {
let moderators =
CommunityModeratorView::for_community(&mut *data.conn().await?, owner.id).await?;
let moderators = CommunityModeratorView::for_community(data.conn().await?, owner.id).await?;
let ordered_items = moderators
.into_iter()
.map(|m| ObjectId::<ApubPerson>::from(m.moderator.actor_id))
@ -64,7 +63,7 @@ impl Collection for ApubCommunityModerators {
) -> Result<Self, LemmyError> {
let community_id = owner.id;
let current_moderators =
CommunityModeratorView::for_community(&mut *data.conn().await?, community_id).await?;
CommunityModeratorView::for_community(data.conn().await?, community_id).await?;
// Remove old mods from database which arent in the moderators collection anymore
for mod_user in &current_moderators {
let mod_id = ObjectId::from(mod_user.moderator.actor_id.clone());
@ -73,7 +72,7 @@ impl Collection for ApubCommunityModerators {
community_id: mod_user.community.id,
person_id: mod_user.moderator.id,
};
CommunityModerator::leave(&mut *data.conn().await?, &community_moderator_form).await?;
CommunityModerator::leave(data.conn().await?, &community_moderator_form).await?;
}
}
@ -90,7 +89,7 @@ impl Collection for ApubCommunityModerators {
community_id: owner.id,
person_id: mod_user.id,
};
CommunityModerator::join(&mut *data.conn().await?, &community_moderator_form).await?;
CommunityModerator::join(data.conn().await?, &community_moderator_form).await?;
}
}

View File

@ -41,14 +41,14 @@ impl Collection for ApubCommunityOutbox {
owner: &Self::Owner,
data: &Data<Self::DataType>,
) -> Result<Self::Kind, LemmyError> {
let post_list: Vec<ApubPost> = Post::list_for_community(&mut *data.conn().await?, owner.id)
let post_list: Vec<ApubPost> = Post::list_for_community(data.conn().await?, owner.id)
.await?
.into_iter()
.map(Into::into)
.collect();
let mut ordered_items = vec![];
for post in post_list {
let person = Person::read(&mut *data.conn().await?, post.creator_id)
let person = Person::read(data.conn().await?, post.creator_id)
.await?
.into();
let create =

View File

@ -176,7 +176,7 @@ where
sensitive: Some(sensitive),
updated: None,
};
Activity::create(&mut *data.conn().await?, &form).await?;
Activity::create(data.conn().await?, &form).await?;
Ok(())
}

View File

@ -83,8 +83,8 @@ impl Object for ApubCommunity {
#[tracing::instrument(skip_all)]
async fn into_json(self, data: &Data<Self::DataType>) -> Result<Group, LemmyError> {
let community_id = self.id;
let langs = CommunityLanguage::read(&mut *data.conn().await?, community_id).await?;
let language = LanguageTag::new_multiple(langs, &mut *data.conn().await?).await?;
let langs = CommunityLanguage::read(data.conn().await?, community_id).await?;
let language = LanguageTag::new_multiple(langs, data.conn().await?).await?;
let group = Group {
kind: GroupType::Group,

View File

@ -71,7 +71,7 @@ impl Object for ApubSite {
data: &Data<Self::DataType>,
) -> Result<Option<Self>, LemmyError> {
Ok(
Site::read_from_apub_id(&mut *data.conn().await?, &object_id.into())
Site::read_from_apub_id(data.conn().await?, &object_id.into())
.await?
.map(Into::into),
)
@ -84,8 +84,8 @@ impl Object for ApubSite {
#[tracing::instrument(skip_all)]
async fn into_json(self, data: &Data<Self::DataType>) -> Result<Self::Kind, LemmyError> {
let site_id = self.id;
let langs = SiteLanguage::read(&mut *data.conn().await?, site_id).await?;
let language = LanguageTag::new_multiple(langs, &mut *data.conn().await?).await?;
let langs = SiteLanguage::read(data.conn().await?, site_id).await?;
let language = LanguageTag::new_multiple(langs, data.conn().await?).await?;
let instance = Instance {
kind: ApplicationType::Application,
@ -113,7 +113,7 @@ impl Object for ApubSite {
expected_domain: &Url,
data: &Data<Self::DataType>,
) -> Result<(), LemmyError> {
let local_site_data = fetch_local_site_data(&mut *data.conn().await?).await?;
let local_site_data = fetch_local_site_data(data.conn().await?).await?;
check_apub_id_valid_with_strictness(apub.id.inner(), true, &local_site_data, data.settings())?;
verify_domains_match(expected_domain, apub.id.inner())?;
@ -128,7 +128,7 @@ impl Object for ApubSite {
#[tracing::instrument(skip_all)]
async fn from_json(apub: Self::Kind, data: &Data<Self::DataType>) -> Result<Self, LemmyError> {
let domain = apub.id.inner().domain().expect("group id has domain");
let instance = DbInstance::read_or_create(&mut *data.conn().await?, domain.to_string()).await?;
let instance = DbInstance::read_or_create(data.conn().await?, domain.to_string()).await?;
let site_form = SiteInsertForm {
name: apub.name.clone(),
@ -144,11 +144,10 @@ impl Object for ApubSite {
private_key: None,
instance_id: instance.id,
};
let languages =
LanguageTag::to_language_id_multiple(apub.language, &mut *data.conn().await?).await?;
let languages = LanguageTag::to_language_id_multiple(apub.language, data.conn().await?).await?;
let site = Site::create(&mut *data.conn().await?, &site_form).await?;
SiteLanguage::update(&mut *data.conn().await?, languages, &site).await?;
let site = Site::create(data.conn().await?, &site_form).await?;
SiteLanguage::update(data.conn().await?, languages, &site).await?;
Ok(site.into())
}
}

View File

@ -124,9 +124,8 @@ async fn get_feed_data(
) -> Result<HttpResponse, LemmyError> {
let site_view = SiteView::read_local(context.conn().await?).await?;
let mut conn = context.conn().await?;
let posts = PostQuery::builder()
.conn(&mut *conn)
.conn(context.conn().await?)
.listing_type(Some(listing_type))
.sort(Some(sort_type))
.limit(Some(limit))