summaryrefslogtreecommitdiffstats
path: root/server/src/apub/shared_inbox.rs
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-04-27 18:17:02 -0400
committerDessalines <tyhou13@gmx.com>2020-04-27 18:17:02 -0400
commit70060c27b2f40ef2de0c0ea37d3d69e202ab8c02 (patch)
tree20f408714ab575852648b525bb3524fb596588d9 /server/src/apub/shared_inbox.rs
parent9c30b37d57ee241ea1b4f1cbc5f6ee0d631c5acf (diff)
Adding activity table inserts.
Diffstat (limited to 'server/src/apub/shared_inbox.rs')
-rw-r--r--server/src/apub/shared_inbox.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/server/src/apub/shared_inbox.rs b/server/src/apub/shared_inbox.rs
index f0cfc990..9ce227e5 100644
--- a/server/src/apub/shared_inbox.rs
+++ b/server/src/apub/shared_inbox.rs
@@ -77,6 +77,15 @@ fn receive_create_post(
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
verify(request, &user.public_key.unwrap())?;
+ // Insert the received activity into the activity table
+ let activity_form = activity::ActivityForm {
+ user_id: user.id,
+ data: serde_json::to_value(&create)?,
+ local: false,
+ updated: None,
+ };
+ activity::Activity::create(&conn, &activity_form)?;
+
let post = PostForm::from_apub(&page, &conn)?;
let inserted_post = Post::create(conn, &post)?;
@@ -110,6 +119,15 @@ fn receive_create_comment(
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
verify(request, &user.public_key.unwrap())?;
+ // Insert the received activity into the activity table
+ let activity_form = activity::ActivityForm {
+ user_id: user.id,
+ data: serde_json::to_value(&create)?,
+ local: false,
+ updated: None,
+ };
+ activity::Activity::create(&conn, &activity_form)?;
+
let comment = CommentForm::from_apub(&note, &conn)?;
let inserted_comment = Comment::create(conn, &comment)?;
@@ -183,6 +201,15 @@ fn receive_update_post(
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
verify(request, &user.public_key.unwrap())?;
+ // Insert the received activity into the activity table
+ let activity_form = activity::ActivityForm {
+ user_id: user.id,
+ data: serde_json::to_value(&update)?,
+ local: false,
+ updated: None,
+ };
+ activity::Activity::create(&conn, &activity_form)?;
+
let post = PostForm::from_apub(&page, conn)?;
let post_id = Post::read_from_apub_id(conn, &post.ap_id)?.id;
Post::update(conn, post_id, &post)?;
@@ -217,6 +244,15 @@ fn receive_update_comment(
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
verify(request, &user.public_key.unwrap())?;
+ // Insert the received activity into the activity table
+ let activity_form = activity::ActivityForm {
+ user_id: user.id,
+ data: serde_json::to_value(&update)?,
+ local: false,
+ updated: None,
+ };
+ activity::Activity::create(&conn, &activity_form)?;
+
let comment = CommentForm::from_apub(&note, &conn)?;
let comment_id = Comment::read_from_apub_id(conn, &comment.ap_id)?.id;
Comment::update(conn, comment_id, &comment)?;