X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fapub%2Fsrc%2Fobjects%2Fcomment.rs;h=2954de0968cab4af742a911b161cfabfdb889c00;hb=92568956353f21649ed9aff68b42699c9d036f30;hp=da844ecc59046861f0076aae613c50dad850955f;hpb=93225e5ddfd48e613afe51984243112a1bedfcc2;p=lemmy.git diff --git a/crates/apub/src/objects/comment.rs b/crates/apub/src/objects/comment.rs index da844ecc..2954de09 100644 --- a/crates/apub/src/objects/comment.rs +++ b/crates/apub/src/objects/comment.rs @@ -66,7 +66,7 @@ impl Object for ApubComment { context: &Data, ) -> Result, LemmyError> { Ok( - Comment::read_from_apub_id(context.pool(), object_id) + Comment::read_from_apub_id(&mut context.pool(), object_id) .await? .map(Into::into), ) @@ -76,7 +76,7 @@ impl Object for ApubComment { async fn delete(self, context: &Data) -> Result<(), LemmyError> { if !self.deleted { let form = CommentUpdateForm::builder().deleted(Some(true)).build(); - Comment::update(context.pool(), self.id, &form).await?; + Comment::update(&mut context.pool(), self.id, &form).await?; } Ok(()) } @@ -84,20 +84,20 @@ impl Object for ApubComment { #[tracing::instrument(skip_all)] async fn into_json(self, context: &Data) -> Result { let creator_id = self.creator_id; - let creator = Person::read(context.pool(), creator_id).await?; + let creator = Person::read(&mut context.pool(), creator_id).await?; let post_id = self.post_id; - let post = Post::read(context.pool(), post_id).await?; + let post = Post::read(&mut context.pool(), post_id).await?; let community_id = post.community_id; - let community = Community::read(context.pool(), community_id).await?; + let community = Community::read(&mut context.pool(), community_id).await?; let in_reply_to = if let Some(comment_id) = self.parent_comment_id() { - let parent_comment = Comment::read(context.pool(), comment_id).await?; + let parent_comment = Comment::read(&mut context.pool(), comment_id).await?; parent_comment.ap_id.into() } else { post.ap_id.into() }; - let language = LanguageTag::new_single(self.language_id, context.pool()).await?; + let language = LanguageTag::new_single(self.language_id, &mut context.pool()).await?; let maa = collect_non_local_mentions(&self, community.actor_id.clone().into(), context).await?; let note = Note { @@ -152,10 +152,11 @@ impl Object for ApubComment { let content = read_from_string_or_source(¬e.content, ¬e.media_type, ¬e.source); - let local_site = LocalSite::read(context.pool()).await.ok(); + let local_site = LocalSite::read(&mut context.pool()).await.ok(); let slur_regex = &local_site_opt_to_slur_regex(&local_site); let content_slurs_removed = remove_slurs(&content, slur_regex); - let language_id = LanguageTag::to_language_id_single(note.language, context.pool()).await?; + let language_id = + LanguageTag::to_language_id_single(note.language, &mut context.pool()).await?; let form = CommentInsertForm { creator_id: creator.id, @@ -171,13 +172,16 @@ impl Object for ApubComment { language_id, }; let parent_comment_path = parent_comment.map(|t| t.0.path); - let comment = Comment::create(context.pool(), &form, parent_comment_path.as_ref()).await?; + let comment = Comment::create(&mut context.pool(), &form, parent_comment_path.as_ref()).await?; Ok(comment.into()) } } #[cfg(test)] pub(crate) mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use super::*; use crate::{ objects::{ @@ -209,11 +213,15 @@ pub(crate) mod tests { } async fn cleanup(data: (ApubPerson, ApubCommunity, ApubPost, ApubSite), context: &LemmyContext) { - Post::delete(context.pool(), data.2.id).await.unwrap(); - Community::delete(context.pool(), data.1.id).await.unwrap(); - Person::delete(context.pool(), data.0.id).await.unwrap(); - Site::delete(context.pool(), data.3.id).await.unwrap(); - LocalSite::delete(context.pool()).await.unwrap(); + Post::delete(&mut context.pool(), data.2.id).await.unwrap(); + Community::delete(&mut context.pool(), data.1.id) + .await + .unwrap(); + Person::delete(&mut context.pool(), data.0.id) + .await + .unwrap(); + Site::delete(&mut context.pool(), data.3.id).await.unwrap(); + LocalSite::delete(&mut context.pool()).await.unwrap(); } #[tokio::test] @@ -238,7 +246,9 @@ pub(crate) mod tests { let to_apub = comment.into_json(&context).await.unwrap(); assert_json_include!(actual: json, expected: to_apub); - Comment::delete(context.pool(), comment_id).await.unwrap(); + Comment::delete(&mut context.pool(), comment_id) + .await + .unwrap(); cleanup(data, &context).await; } @@ -268,7 +278,9 @@ pub(crate) mod tests { assert!(!comment.local); assert_eq!(context.request_count(), 1); - Comment::delete(context.pool(), comment.id).await.unwrap(); + Comment::delete(&mut context.pool(), comment.id) + .await + .unwrap(); cleanup(data, &context).await; }