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::{
&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;
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::{
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,
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};
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,
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};
) -> 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,