Fixing clippy lints. (#1885)

* Fixing clippy lints.

* Revert object id display

* Trying to fix clippy again
pull/1891/head
Dessalines 2021-11-09 13:16:37 -05:00 committed by GitHub
parent c03689ed4c
commit 76220a4523
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 22 additions and 22 deletions

View File

@ -194,7 +194,7 @@ impl Perform for CreateCommentLike {
// Only add the like if the score isnt 0 // Only add the like if the score isnt 0
let comment = orig_comment.comment; let comment = orig_comment.comment;
let object = PostOrComment::Comment(comment.into()); let object = PostOrComment::Comment(Box::new(comment.into()));
let do_add = like_form.score != 0 && (like_form.score == 1 || like_form.score == -1); let do_add = like_form.score != 0 && (like_form.score == 1 || like_form.score == -1);
if do_add { if do_add {
let like_form2 = like_form.clone(); let like_form2 = like_form.clone();

View File

@ -73,7 +73,7 @@ impl Perform for CreatePostLike {
.await??; .await??;
let community_id = post.community_id; let community_id = post.community_id;
let object = PostOrComment::Post(post); let object = PostOrComment::Post(Box::new(post));
// Only add the like if the score isnt 0 // Only add the like if the score isnt 0
let do_add = like_form.score != 0 && (like_form.score == 1 || like_form.score == -1); let do_add = like_form.score != 0 && (like_form.score == 1 || like_form.score == -1);

View File

@ -154,7 +154,7 @@ impl PerformCrud for CreateComment {
context, context,
) )
.await?; .await?;
let object = PostOrComment::Comment(apub_comment); let object = PostOrComment::Comment(Box::new(apub_comment));
Vote::send( Vote::send(
&object, &object,
&local_user_view.person.clone().into(), &local_user_view.person.clone().into(),

View File

@ -146,7 +146,7 @@ impl PerformCrud for CreatePost {
context, context,
) )
.await?; .await?;
let object = PostOrComment::Post(apub_post); let object = PostOrComment::Post(Box::new(apub_post));
Vote::send( Vote::send(
&object, &object,
&local_user_view.person.clone().into(), &local_user_view.person.clone().into(),

View File

@ -53,9 +53,9 @@ pub async fn send_apub_remove(
} }
pub enum DeletableObjects { pub enum DeletableObjects {
Community(ApubCommunity), Community(Box<ApubCommunity>),
Comment(ApubComment), Comment(Box<ApubComment>),
Post(ApubPost), Post(Box<ApubPost>),
} }
impl DeletableObjects { impl DeletableObjects {
@ -64,13 +64,13 @@ impl DeletableObjects {
context: &LemmyContext, context: &LemmyContext,
) -> Result<DeletableObjects, LemmyError> { ) -> Result<DeletableObjects, LemmyError> {
if let Some(c) = ApubCommunity::read_from_apub_id(ap_id.clone(), context).await? { if let Some(c) = ApubCommunity::read_from_apub_id(ap_id.clone(), context).await? {
return Ok(DeletableObjects::Community(c)); return Ok(DeletableObjects::Community(Box::new(c)));
} }
if let Some(p) = ApubPost::read_from_apub_id(ap_id.clone(), context).await? { if let Some(p) = ApubPost::read_from_apub_id(ap_id.clone(), context).await? {
return Ok(DeletableObjects::Post(p)); return Ok(DeletableObjects::Post(Box::new(p)));
} }
if let Some(c) = ApubComment::read_from_apub_id(ap_id.clone(), context).await? { if let Some(c) = ApubComment::read_from_apub_id(ap_id.clone(), context).await? {
return Ok(DeletableObjects::Comment(c)); return Ok(DeletableObjects::Comment(Box::new(c)));
} }
Err(diesel::NotFound.into()) Err(diesel::NotFound.into())
} }

View File

@ -35,7 +35,7 @@ use serde::{Deserialize, Serialize};
#[serde(untagged)] #[serde(untagged)]
#[activity_handler(LemmyContext)] #[activity_handler(LemmyContext)]
pub enum SharedInboxActivities { pub enum SharedInboxActivities {
GroupInboxActivities(GroupInboxActivities), GroupInboxActivities(Box<GroupInboxActivities>),
// Note, pm activities need to be at the end, otherwise comments will end up here. We can probably // Note, pm activities need to be at the end, otherwise comments will end up here. We can probably
// avoid this problem by replacing createpm.object with our own struct, instead of NoteExt. // avoid this problem by replacing createpm.object with our own struct, instead of NoteExt.
PersonInboxActivities(Box<PersonInboxActivities>), PersonInboxActivities(Box<PersonInboxActivities>),

View File

@ -11,8 +11,8 @@ use url::Url;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub enum PostOrComment { pub enum PostOrComment {
Post(ApubPost), Post(Box<ApubPost>),
Comment(ApubComment), Comment(Box<ApubComment>),
} }
#[derive(Deserialize)] #[derive(Deserialize)]
@ -39,10 +39,10 @@ impl ApubObject for PostOrComment {
) -> Result<Option<Self>, LemmyError> { ) -> Result<Option<Self>, LemmyError> {
let post = ApubPost::read_from_apub_id(object_id.clone(), data).await?; let post = ApubPost::read_from_apub_id(object_id.clone(), data).await?;
Ok(match post { Ok(match post {
Some(o) => Some(PostOrComment::Post(o)), Some(o) => Some(PostOrComment::Post(Box::new(o))),
None => ApubComment::read_from_apub_id(object_id, data) None => ApubComment::read_from_apub_id(object_id, data)
.await? .await?
.map(PostOrComment::Comment), .map(|c| PostOrComment::Comment(Box::new(c))),
}) })
} }
@ -79,12 +79,12 @@ impl ApubObject for PostOrComment {
request_counter: &mut i32, request_counter: &mut i32,
) -> Result<Self, LemmyError> { ) -> Result<Self, LemmyError> {
Ok(match apub { Ok(match apub {
PageOrNote::Page(p) => { PageOrNote::Page(p) => PostOrComment::Post(Box::new(
PostOrComment::Post(ApubPost::from_apub(p, context, request_counter).await?) ApubPost::from_apub(p, context, request_counter).await?,
} )),
PageOrNote::Note(n) => { PageOrNote::Note(n) => PostOrComment::Comment(Box::new(
PostOrComment::Comment(ApubComment::from_apub(n, context, request_counter).await?) ApubComment::from_apub(n, context, request_counter).await?,
} )),
}) })
} }
} }

View File

@ -49,7 +49,7 @@ pub async fn shared_inbox(
let activity = serde_json::from_str::<WithContext<SharedInboxActivities>>(&unparsed)?; let activity = serde_json::from_str::<WithContext<SharedInboxActivities>>(&unparsed)?;
match activity.inner() { match activity.inner() {
SharedInboxActivities::GroupInboxActivities(g) => { SharedInboxActivities::GroupInboxActivities(g) => {
receive_group_inbox(g, activity_data, request, &context).await receive_group_inbox(*g, activity_data, request, &context).await
} }
SharedInboxActivities::PersonInboxActivities(p) => { SharedInboxActivities::PersonInboxActivities(p) => {
receive_person_inbox(*p, activity_data, request, &context).await receive_person_inbox(*p, activity_data, request, &context).await