mirror of https://github.com/LemmyNet/lemmy.git
Create and Note always need to tag parent creator, for mastodon notifications
parent
12c51ab435
commit
659572e00e
|
@ -50,7 +50,7 @@ impl CreateOrUpdateComment {
|
||||||
)?;
|
)?;
|
||||||
let maa = collect_non_local_mentions(&comment, &community, context).await?;
|
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()),
|
actor: ObjectId::new(actor.actor_id()),
|
||||||
to: vec![public()],
|
to: vec![public()],
|
||||||
object: comment.into_apub(context).await?,
|
object: comment.into_apub(context).await?,
|
||||||
|
@ -61,6 +61,11 @@ impl CreateOrUpdateComment {
|
||||||
unparsed: Default::default(),
|
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);
|
let activity = AnnouncableActivities::CreateOrUpdateComment(create_or_update);
|
||||||
send_activity_in_community(activity, &id, actor, &community, maa.inboxes, context).await
|
send_activity_in_community(activity, &id, actor, &community, maa.inboxes, context).await
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ use crate::{
|
||||||
fetcher::webfinger::WebfingerResponse,
|
fetcher::webfinger::WebfingerResponse,
|
||||||
objects::{comment::ApubComment, community::ApubCommunity, person::ApubPerson},
|
objects::{comment::ApubComment, community::ApubCommunity, person::ApubPerson},
|
||||||
};
|
};
|
||||||
|
use lemmy_utils::settings::structs::Settings;
|
||||||
|
|
||||||
pub mod create_or_update;
|
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()];
|
let mut inboxes = vec![parent_creator.shared_inbox_or_inbox_url()];
|
||||||
|
|
||||||
// Add the mention tag
|
// 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
|
// Get the person IDs for any mentions
|
||||||
let mentions = scrape_text_for_mentions(&comment.content)
|
let mentions = scrape_text_for_mentions(&comment.content)
|
||||||
|
|
|
@ -117,6 +117,7 @@ impl ApubObject for ApubComment {
|
||||||
in_reply_to,
|
in_reply_to,
|
||||||
published: Some(convert_datetime(self.published)),
|
published: Some(convert_datetime(self.published)),
|
||||||
updated: self.updated.map(convert_datetime),
|
updated: self.updated.map(convert_datetime),
|
||||||
|
tag: None,
|
||||||
unparsed: Default::default(),
|
unparsed: Default::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use crate::{
|
||||||
objects::{comment::ApubComment, person::ApubPerson, post::ApubPost},
|
objects::{comment::ApubComment, person::ApubPerson, post::ApubPost},
|
||||||
protocol::Source,
|
protocol::Source,
|
||||||
};
|
};
|
||||||
use activitystreams::{object::kind::NoteType, unparsed::Unparsed};
|
use activitystreams::{link::Mention, object::kind::NoteType, unparsed::Unparsed};
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use chrono::{DateTime, FixedOffset};
|
use chrono::{DateTime, FixedOffset};
|
||||||
use lemmy_api_common::blocking;
|
use lemmy_api_common::blocking;
|
||||||
|
@ -38,6 +38,7 @@ pub struct Note {
|
||||||
pub(crate) in_reply_to: ObjectId<PostOrComment>,
|
pub(crate) in_reply_to: ObjectId<PostOrComment>,
|
||||||
pub(crate) published: Option<DateTime<FixedOffset>>,
|
pub(crate) published: Option<DateTime<FixedOffset>>,
|
||||||
pub(crate) updated: Option<DateTime<FixedOffset>>,
|
pub(crate) updated: Option<DateTime<FixedOffset>>,
|
||||||
|
pub(crate) tag: Option<Vec<Mention>>,
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub(crate) unparsed: Unparsed,
|
pub(crate) unparsed: Unparsed,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue