- let announce = AnnounceActivity {
- actor: community.actor_id(),
- to: [PublicUrl::Public],
- object,
- cc: vec![community.followers_url()],
- kind: AnnounceType::Announce,
- id: generate_activity_id(&AnnounceType::Announce)?,
- context: lemmy_context(),
- unparsed: Default::default(),
- };
- let inboxes = list_community_follower_inboxes(community, additional_inboxes, context).await?;
- send_activity_new(context, &announce, &announce.id, community, inboxes, false).await
+ let announce = AnnounceActivity::new(object.clone(), community, context)?;
+ let inboxes = community.get_follower_inboxes(context).await?;
+ send_lemmy_activity(context, announce, community, inboxes.clone(), false).await?;
+
+ // Pleroma and Mastodon can't handle activities like Announce/Create/Page. So for
+ // compatibility, we also send Announce/Page so that they can follow Lemmy communities.
+ let object_parsed = object.try_into()?;
+ if let AnnouncableActivities::CreateOrUpdatePost(c) = object_parsed {
+ // Hack: need to convert Page into a format which can be sent as activity, which requires
+ // adding actor field.
+ let announcable_page = RawAnnouncableActivities {
+ id: generate_activity_id(
+ AnnounceType::Announce,
+ &context.settings().get_protocol_and_hostname(),
+ )?,
+ actor: c.actor.clone().into_inner(),
+ other: serde_json::to_value(c.object)?
+ .as_object()
+ .expect("is object")
+ .clone(),
+ };
+ let announce_compat = AnnounceActivity::new(announcable_page, community, context)?;
+ send_lemmy_activity(context, announce_compat, community, inboxes, false).await?;
+ }
+ Ok(())