]> Untitled Git - lemmy.git/commitdiff
fix comment notifications
authorFelix Ableitner <me@nutomic.com>
Sat, 30 May 2020 18:05:42 +0000 (20:05 +0200)
committerFelix Ableitner <me@nutomic.com>
Sat, 30 May 2020 18:05:42 +0000 (20:05 +0200)
server/src/apub/comment.rs
server/src/apub/community.rs
server/src/apub/post.rs
server/src/apub/shared_inbox.rs

index 992ad26b7cf24737b70d6c19b0fb9241a80130cf..d199eddbfb8c49b7165b1224f2326f4b47f0fe0b 100644 (file)
@@ -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<String>,
     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(())
   }
index 6ed10f3b202ad2a6a2add158e17639091ac26f1d..9cd65334ec2e5ccc819cef4bc89173e7e20e3354 100644 (file)
@@ -384,8 +384,7 @@ pub async fn get_apub_community_followers(
 impl Community {
   pub fn do_announce<A>(
     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())
   }
index a6dcc5ba62cc2b257dd02c300fc9220133285df6..2b8455d53be08994fd6a0dc9095b30d2039736bb 100644 (file)
@@ -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()])?;
     }
index 55395f0339ce2687a4a7745e7e14aac0664cb06e..b4a214a0d7318f88fa4f1c67bb943b96cdc74bee 100644 (file)
@@ -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(