Dont federate initial upvote (#2196)

This commit is contained in:
Nutomic 2022-04-07 20:46:10 +00:00 committed by GitHub
parent f9d563d80a
commit 9ac1f46a2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 33 deletions

View file

@ -10,14 +10,9 @@ use lemmy_api_common::{
get_post,
};
use lemmy_apub::{
fetcher::post_or_comment::PostOrComment,
generate_local_apub_endpoint,
objects::comment::ApubComment,
protocol::activities::{
create_or_update::comment::CreateOrUpdateComment,
voting::vote::{Vote, VoteType},
CreateOrUpdateType,
},
protocol::activities::{create_or_update::comment::CreateOrUpdateComment, CreateOrUpdateType},
EndpointType,
};
use lemmy_db_schema::{
@ -150,15 +145,6 @@ impl PerformCrud for CreateComment {
&mut 0,
)
.await?;
let object = PostOrComment::Comment(Box::new(apub_comment));
Vote::send(
&object,
&local_user_view.person.clone().into(),
community_id,
VoteType::Like,
context,
)
.await?;
let person_id = local_user_view.person.id;
let comment_id = inserted_comment.id;

View file

@ -10,14 +10,9 @@ use lemmy_api_common::{
post::*,
};
use lemmy_apub::{
fetcher::post_or_comment::PostOrComment,
generate_local_apub_endpoint,
objects::post::ApubPost,
protocol::activities::{
create_or_update::post::CreateOrUpdatePost,
voting::vote::{Vote, VoteType},
CreateOrUpdateType,
},
protocol::activities::{create_or_update::post::CreateOrUpdatePost, CreateOrUpdateType},
EndpointType,
};
use lemmy_db_schema::{
@ -156,15 +151,6 @@ impl PerformCrud for CreatePost {
context,
)
.await?;
let object = PostOrComment::Post(Box::new(apub_post));
Vote::send(
&object,
&local_user_view.person.clone().into(),
inserted_post.community_id,
VoteType::Like,
context,
)
.await?;
send_post_ws_message(
inserted_post.id,

View file

@ -21,8 +21,12 @@ use lemmy_apub_lib::{
verify::verify_domains_match,
};
use lemmy_db_schema::{
source::{community::Community, post::Post},
traits::Crud,
source::{
comment::{CommentLike, CommentLikeForm},
community::Community,
post::Post,
},
traits::{Crud, Likeable},
};
use lemmy_utils::LemmyError;
use lemmy_websocket::{send::send_comment_ws_message, LemmyContext, UserOperationCrud};
@ -113,6 +117,19 @@ impl ActivityHandler for CreateOrUpdateComment {
request_counter: &mut i32,
) -> Result<(), LemmyError> {
let comment = ApubComment::from_apub(self.object, context, request_counter).await?;
// author likes their own comment by default
let like_form = CommentLikeForm {
comment_id: comment.id,
post_id: comment.post_id,
person_id: comment.creator_id,
score: 1,
};
blocking(context.pool(), move |conn: &'_ _| {
CommentLike::like(conn, &like_form)
})
.await??;
let do_send_email = self.kind == CreateOrUpdateType::Create;
let recipients = get_comment_notif_recipients(
&self.actor,

View file

@ -20,7 +20,13 @@ use lemmy_apub_lib::{
traits::{ActivityHandler, ActorType, ApubObject},
verify::{verify_domains_match, verify_urls_match},
};
use lemmy_db_schema::{source::community::Community, traits::Crud};
use lemmy_db_schema::{
source::{
community::Community,
post::{PostLike, PostLikeForm},
},
traits::{Crud, Likeable},
};
use lemmy_utils::LemmyError;
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud};
@ -129,6 +135,17 @@ impl ActivityHandler for CreateOrUpdatePost {
) -> Result<(), LemmyError> {
let post = ApubPost::from_apub(self.object, context, request_counter).await?;
// author likes their own post by default
let like_form = PostLikeForm {
post_id: post.id,
person_id: post.creator_id,
score: 1,
};
blocking(context.pool(), move |conn: &'_ _| {
PostLike::like(conn, &like_form)
})
.await??;
let notif_type = match self.kind {
CreateOrUpdateType::Create => UserOperationCrud::CreatePost,
CreateOrUpdateType::Update => UserOperationCrud::EditPost,