diff --git a/crates/apub/src/activities/comment/create_or_update.rs b/crates/apub/src/activities/comment/create_or_update.rs index eab2a5771..ab59eb703 100644 --- a/crates/apub/src/activities/comment/create_or_update.rs +++ b/crates/apub/src/activities/comment/create_or_update.rs @@ -50,7 +50,7 @@ impl CreateOrUpdateComment { )?; let maa = collect_non_local_mentions(&comment, &community, context).await?; - let create_or_update = CreateOrUpdateComment { + let mut create_or_update = CreateOrUpdateComment { actor: ObjectId::new(actor.actor_id()), to: vec![public()], object: comment.into_apub(context).await?, @@ -61,6 +61,11 @@ impl CreateOrUpdateComment { unparsed: Default::default(), }; + // To make mention notifications work on Mastodon/Pleroma, it is necessary that tag and cc + // are set on both the activity and the object. + create_or_update.object.tag = Some(create_or_update.tag.clone()); + create_or_update.object.cc = create_or_update.cc.clone(); + let activity = AnnouncableActivities::CreateOrUpdateComment(create_or_update); send_activity_in_community(activity, &id, actor, &community, maa.inboxes, context).await } diff --git a/crates/apub/src/activities/comment/mod.rs b/crates/apub/src/activities/comment/mod.rs index d104db2fe..f0468f970 100644 --- a/crates/apub/src/activities/comment/mod.rs +++ b/crates/apub/src/activities/comment/mod.rs @@ -26,6 +26,7 @@ use crate::{ fetcher::webfinger::WebfingerResponse, objects::{comment::ApubComment, community::ApubCommunity, person::ApubPerson}, }; +use lemmy_utils::settings::structs::Settings; pub mod create_or_update; @@ -68,7 +69,15 @@ pub async fn collect_non_local_mentions( let mut inboxes = vec![parent_creator.shared_inbox_or_inbox_url()]; // Add the mention tag - let mut tags = Vec::new(); + let mut parent_creator_tag = Mention::new(); + parent_creator_tag + .set_href(parent_creator.actor_id.clone().into()) + .set_name(format!( + "@{}@{}", + &parent_creator.name, + &Settings::get().hostname + )); + let mut tags = vec![parent_creator_tag]; // Get the person IDs for any mentions let mentions = scrape_text_for_mentions(&comment.content) diff --git a/crates/apub/src/objects/comment.rs b/crates/apub/src/objects/comment.rs index 83895e8d3..b3f520dae 100644 --- a/crates/apub/src/objects/comment.rs +++ b/crates/apub/src/objects/comment.rs @@ -117,6 +117,7 @@ impl ApubObject for ApubComment { in_reply_to, published: Some(convert_datetime(self.published)), updated: self.updated.map(convert_datetime), + tag: None, unparsed: Default::default(), }; diff --git a/crates/apub/src/protocol/objects/note.rs b/crates/apub/src/protocol/objects/note.rs index 784e6f9f8..5bcd1a553 100644 --- a/crates/apub/src/protocol/objects/note.rs +++ b/crates/apub/src/protocol/objects/note.rs @@ -3,7 +3,7 @@ use crate::{ objects::{comment::ApubComment, person::ApubPerson, post::ApubPost}, protocol::Source, }; -use activitystreams::{object::kind::NoteType, unparsed::Unparsed}; +use activitystreams::{link::Mention, object::kind::NoteType, unparsed::Unparsed}; use anyhow::anyhow; use chrono::{DateTime, FixedOffset}; use lemmy_api_common::blocking; @@ -38,6 +38,7 @@ pub struct Note { pub(crate) in_reply_to: ObjectId, pub(crate) published: Option>, pub(crate) updated: Option>, + pub(crate) tag: Option>, #[serde(flatten)] pub(crate) unparsed: Unparsed, }