From: Felix Ableitner Date: Sat, 30 May 2020 18:05:42 +0000 (+0200) Subject: fix comment notifications X-Git-Url: http://these/git/%22https:/www.exeterceilidhs.net/%22?a=commitdiff_plain;h=f3aba6da92702b2039c51ad54aef8c5cb0a8ecf2;p=lemmy.git fix comment notifications --- diff --git a/server/src/apub/comment.rs b/server/src/apub/comment.rs index 992ad26b..d199eddb 100644 --- a/server/src/apub/comment.rs +++ b/server/src/apub/comment.rs @@ -178,7 +178,7 @@ impl ApubObjectType for Comment { .set_actor_xsd_any_uri(creator.actor_id.to_owned())? .set_object_base_box(note)?; - Comment::send_comment_activity(&creator, &conn, &community, create)?; + Comment::send_comment_activity(&creator, &conn, &community, maa.inboxes,create)?; Ok(()) } @@ -203,7 +203,7 @@ impl ApubObjectType for Comment { .set_actor_xsd_any_uri(creator.actor_id.to_owned())? .set_object_base_box(note)?; - Comment::send_comment_activity(&creator, &conn, &community, update)?; + Comment::send_comment_activity(&creator, &conn, &community, maa.inboxes, update)?; Ok(()) } @@ -225,7 +225,7 @@ impl ApubObjectType for Comment { .set_actor_xsd_any_uri(creator.actor_id.to_owned())? .set_object_base_box(note)?; - Comment::send_comment_activity(&creator, &conn, &community, delete)?; + Comment::send_comment_activity(&creator, &conn, &community,vec!(community.get_shared_inbox_url()), delete)?; Ok(()) } @@ -265,7 +265,7 @@ impl ApubObjectType for Comment { .set_actor_xsd_any_uri(creator.actor_id.to_owned())? .set_object_base_box(delete)?; - Comment::send_comment_activity(&creator, &conn, &community, undo)?; + Comment::send_comment_activity(&creator, &conn, &community, vec!(community.get_shared_inbox_url()),undo)?; Ok(()) } @@ -287,7 +287,7 @@ impl ApubObjectType for Comment { .set_actor_xsd_any_uri(mod_.actor_id.to_owned())? .set_object_base_box(note)?; - Comment::send_comment_activity(&mod_, &conn, &community, remove)?; + Comment::send_comment_activity(&mod_, &conn, &community, vec!(community.get_shared_inbox_url()),remove)?; Ok(()) } @@ -326,7 +326,7 @@ impl ApubObjectType for Comment { .set_actor_xsd_any_uri(mod_.actor_id.to_owned())? .set_object_base_box(remove)?; - Comment::send_comment_activity(&mod_, &conn, &community, undo)?; + Comment::send_comment_activity(&mod_, &conn, &community, vec!(community.get_shared_inbox_url()),undo)?; Ok(()) } } @@ -349,7 +349,7 @@ impl ApubLikeableType for Comment { .set_actor_xsd_any_uri(creator.actor_id.to_owned())? .set_object_base_box(note)?; - Comment::send_comment_activity(&creator, &conn, &community, like)?; + Comment::send_comment_activity(&creator, &conn, &community, vec!(community.get_shared_inbox_url()),like)?; Ok(()) } @@ -370,7 +370,7 @@ impl ApubLikeableType for Comment { .set_actor_xsd_any_uri(creator.actor_id.to_owned())? .set_object_base_box(note)?; - Comment::send_comment_activity(&creator, &conn, &community, dislike)?; + Comment::send_comment_activity(&creator, &conn, &community, vec!(community.get_shared_inbox_url()),dislike)?; Ok(()) } @@ -407,7 +407,7 @@ impl ApubLikeableType for Comment { .set_actor_xsd_any_uri(creator.actor_id.to_owned())? .set_object_base_box(like)?; - Comment::send_comment_activity(&creator, &conn, &community, undo)?; + Comment::send_comment_activity(&creator, &conn, &community, vec!(community.get_shared_inbox_url()), undo)?; Ok(()) } } @@ -455,7 +455,7 @@ fn collect_non_local_mentions_and_addresses( } } - let mut inboxes = community.get_follower_inboxes(&conn)?; + let mut inboxes = vec!(community.get_shared_inbox_url()); inboxes.extend(mention_inboxes); inboxes = inboxes.into_iter().unique().collect(); @@ -471,6 +471,7 @@ impl Comment { creator: &User_, conn: &PgConnection, community: &Community, + to: Vec, activity: A, ) -> Result<(), Error> where @@ -480,9 +481,9 @@ impl Comment { // if this is a local community, we need to do an announce from the community instead if community.local { - Community::do_announce(activity, &community.actor_id, &creator.actor_id, conn, true)?; + Community::do_announce(activity, &community, &creator.actor_id, conn, true)?; } else { - send_activity(&activity, creator, vec![community.get_shared_inbox_url()])?; + send_activity(&activity, creator, to)?; } Ok(()) } diff --git a/server/src/apub/community.rs b/server/src/apub/community.rs index 6ed10f3b..9cd65334 100644 --- a/server/src/apub/community.rs +++ b/server/src/apub/community.rs @@ -384,8 +384,7 @@ pub async fn get_apub_community_followers( impl Community { pub fn do_announce( activity: A, - // TODO: maybe pass in the community object - community_uri: &str, + community: &Community, sender: &str, conn: &PgConnection, is_local_activity: bool, @@ -393,8 +392,6 @@ impl Community { where A: Activity + Base + Serialize + Debug, { - let community = Community::read_from_actor_id(conn, &community_uri)?; - insert_activity(&conn, -1, &activity, is_local_activity)?; let mut announce = Announce::default(); @@ -417,7 +414,7 @@ impl Community { // this seems to be the "easiest" stable alternative for remove_item() to.retain(|x| *x != sending_user.get_shared_inbox_url()); - send_activity(&announce, &community, to)?; + send_activity(&announce, community, to)?; Ok(HttpResponse::Ok().finish()) } diff --git a/server/src/apub/post.rs b/server/src/apub/post.rs index a6dcc5ba..2b8455d5 100644 --- a/server/src/apub/post.rs +++ b/server/src/apub/post.rs @@ -479,7 +479,7 @@ impl Post { // if this is a local community, we need to do an announce from the community instead if community.local { - Community::do_announce(activity, &community.actor_id, &creator.actor_id, conn, true)?; + Community::do_announce(activity, &community, &creator.actor_id, conn, true)?; } else { send_activity(&activity, creator, vec![community.get_shared_inbox_url()])?; } diff --git a/server/src/apub/shared_inbox.rs b/server/src/apub/shared_inbox.rs index 55395f03..b4a214a0 100644 --- a/server/src/apub/shared_inbox.rs +++ b/server/src/apub/shared_inbox.rs @@ -220,7 +220,7 @@ where if !community.local { // ignore this object } - Community::do_announce(activity, &community_uri, sender, conn, false) + Community::do_announce(activity, &community, sender, conn, false) } fn receive_announce(