diff options
author | Dessalines <dessalines@users.noreply.github.com> | 2020-05-15 12:36:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-15 12:36:11 -0400 |
commit | 940dc73f280742e553395d6a56eaca015a234b3a (patch) | |
tree | e81748decb1dc10d1ace2ad6318a94d063ccf23c /server/src/apub/shared_inbox.rs | |
parent | 3a4973ad68562f9ccb4a9f4442333e0478bc7b04 (diff) |
Federated mentions. Fixes #681 (#717)
* Federated mentions. Fixes #681
* Changing some todos, adding comments.
Diffstat (limited to 'server/src/apub/shared_inbox.rs')
-rw-r--r-- | server/src/apub/shared_inbox.rs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/server/src/apub/shared_inbox.rs b/server/src/apub/shared_inbox.rs index 6bbe9725..b65f3a8a 100644 --- a/server/src/apub/shared_inbox.rs +++ b/server/src/apub/shared_inbox.rs @@ -167,12 +167,18 @@ fn receive_create_comment( let comment = CommentForm::from_apub(¬e, &conn)?; let inserted_comment = Comment::create(conn, &comment)?; + let post = Post::read(&conn, inserted_comment.post_id)?; + + // Note: + // Although mentions could be gotten from the post tags (they are included there), or the ccs, + // Its much easier to scrape them from the comment body, since the API has to do that + // anyway. + let mentions = scrape_text_for_mentions(&inserted_comment.content); + let recipient_ids = send_local_notifs(&conn, &mentions, &inserted_comment, &user, &post); // Refetch the view let comment_view = CommentView::read(&conn, inserted_comment.id, None)?; - // TODO get those recipient actor ids from somewhere - let recipient_ids = vec![]; let res = CommentResponse { comment: comment_view, recipient_ids, @@ -353,13 +359,15 @@ fn receive_update_comment( let comment = CommentForm::from_apub(¬e, &conn)?; let comment_id = Comment::read_from_apub_id(conn, &comment.ap_id)?.id; - Comment::update(conn, comment_id, &comment)?; + let updated_comment = Comment::update(conn, comment_id, &comment)?; + let post = Post::read(&conn, updated_comment.post_id)?; + + let mentions = scrape_text_for_mentions(&updated_comment.content); + let recipient_ids = send_local_notifs(&conn, &mentions, &updated_comment, &user, &post); // Refetch the view let comment_view = CommentView::read(&conn, comment_id, None)?; - // TODO get those recipient actor ids from somewhere - let recipient_ids = vec![]; let res = CommentResponse { comment: comment_view, recipient_ids, |