verify_person_in_community,
},
activity_lists::AnnouncableActivities,
- insert_activity,
+ insert_received_activity,
mentions::MentionOrValue,
objects::{comment::ApubComment, community::ApubCommunity, person::ApubPerson},
protocol::{
utils::{check_post_deleted_or_removed, is_mod_or_admin},
};
use lemmy_db_schema::{
+ aggregates::structs::CommentAggregates,
newtypes::PersonId,
source::{
comment::{Comment, CommentLike, CommentLikeForm},
) -> Result<(), LemmyError> {
// TODO: might be helpful to add a comment method to retrieve community directly
let post_id = comment.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 person: ApubPerson = Person::read(context.pool(), person_id).await?.into();
- let community: ApubCommunity = Community::read(context.pool(), community_id).await?.into();
+ let person: ApubPerson = Person::read(&mut context.pool(), person_id).await?.into();
+ let community: ApubCommunity = Community::read(&mut context.pool(), community_id)
+ .await?
+ .into();
let id = generate_activity_id(
kind.clone(),
#[tracing::instrument(skip_all)]
async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
+ insert_received_activity(&self.id, context).await?;
verify_is_public(&self.to, &self.cc)?;
let post = self.object.get_parents(context).await?.0;
let community = self.community(context).await?;
#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
- insert_activity(&self.id, &self, false, false, context).await?;
// Need to do this check here instead of Note::from_json because we need the person who
// send the activity, not the comment author.
let existing_comment = self.object.id.dereference_local(context).await.ok();
if distinguished != existing_comment.distinguished {
let creator = self.actor.dereference(context).await?;
let (post, _) = self.object.get_parents(context).await?;
- is_mod_or_admin(context.pool(), creator.id, post.community_id).await?;
+ is_mod_or_admin(&mut context.pool(), creator.id, post.community_id).await?;
}
}
person_id: comment.creator_id,
score: 1,
};
- CommentLike::like(context.pool(), &like_form).await?;
+ CommentLike::like(&mut context.pool(), &like_form).await?;
+
+ // Calculate initial hot_rank
+ CommentAggregates::update_hot_rank(&mut context.pool(), comment.id).await?;
let do_send_email = self.kind == CreateOrUpdateType::Create;
let post_id = comment.post_id;
- let post = Post::read(context.pool(), post_id).await?;
+ let post = Post::read(&mut context.pool(), post_id).await?;
let actor = self.actor.dereference(context).await?;
// Note: