summaryrefslogtreecommitdiffstats
path: root/server/src/apub/shared_inbox.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/apub/shared_inbox.rs')
-rw-r--r--server/src/apub/shared_inbox.rs109
1 files changed, 50 insertions, 59 deletions
diff --git a/server/src/apub/shared_inbox.rs b/server/src/apub/shared_inbox.rs
index 75ce3415..f0f5bbfd 100644
--- a/server/src/apub/shared_inbox.rs
+++ b/server/src/apub/shared_inbox.rs
@@ -8,15 +8,10 @@ use crate::{
community::do_announce,
extensions::signatures::verify,
fetcher::{
- get_or_fetch_and_insert_remote_comment,
- get_or_fetch_and_insert_remote_post,
- get_or_fetch_and_upsert_remote_community,
- get_or_fetch_and_upsert_remote_user,
+ get_or_fetch_and_insert_remote_comment, get_or_fetch_and_insert_remote_post,
+ get_or_fetch_and_upsert_remote_community, get_or_fetch_and_upsert_remote_user,
},
- insert_activity,
- FromApub,
- GroupExt,
- PageExt,
+ insert_activity, FromApub, GroupExt, PageExt,
},
blocking,
routes::{ChatServerParam, DbPoolParam},
@@ -24,15 +19,12 @@ use crate::{
server::{SendComment, SendCommunityRoomMessage, SendPost},
UserOperation,
},
- DbPool,
- LemmyError,
+ DbPool, LemmyError,
};
use activitystreams::{
activity::{Announce, Create, Delete, Dislike, Like, Remove, Undo, Update},
object::Note,
- Activity,
- Base,
- BaseBox,
+ Activity, Base, BaseBox,
};
use actix_web::{client::Client, web, HttpRequest, HttpResponse};
use lemmy_db::{
@@ -43,8 +35,7 @@ use lemmy_db::{
naive_now,
post::{Post, PostForm, PostLike, PostLikeForm},
post_view::PostView,
- Crud,
- Likeable,
+ Crud, Likeable,
};
use lemmy_utils::scrape_text_for_mentions;
use log::debug;
@@ -336,7 +327,7 @@ async fn receive_create_post(
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut page = create
+ let page = create
.create_props
.get_object_base_box()
.to_owned()
@@ -354,7 +345,7 @@ async fn receive_create_post(
insert_activity(user.id, create, false, pool).await?;
- let post = PostForm::from_apub(&mut page, client, pool).await?;
+ let post = PostForm::from_apub(&page, client, pool).await?;
let inserted_post = blocking(pool, move |conn| Post::create(conn, &post)).await??;
@@ -382,7 +373,7 @@ async fn receive_create_comment(
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut note = create
+ let note = create
.create_props
.get_object_base_box()
.to_owned()
@@ -400,7 +391,7 @@ async fn receive_create_comment(
insert_activity(user.id, create, false, pool).await?;
- let comment = CommentForm::from_apub(&mut note, client, pool).await?;
+ let comment = CommentForm::from_apub(&note, client, pool).await?;
let inserted_comment = blocking(pool, move |conn| Comment::create(conn, &comment)).await??;
@@ -441,7 +432,7 @@ async fn receive_update_post(
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut page = update
+ let page = update
.update_props
.get_object_base_box()
.to_owned()
@@ -459,7 +450,7 @@ async fn receive_update_post(
insert_activity(user.id, update, false, pool).await?;
- let post = PostForm::from_apub(&mut page, client, pool).await?;
+ let post = PostForm::from_apub(&page, client, pool).await?;
let post_id = get_or_fetch_and_insert_remote_post(&post.ap_id, client, pool)
.await?
@@ -487,7 +478,7 @@ async fn receive_like_post(
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut page = like
+ let page = like
.like_props
.get_object_base_box()
.to_owned()
@@ -501,7 +492,7 @@ async fn receive_like_post(
insert_activity(user.id, like, false, pool).await?;
- let post = PostForm::from_apub(&mut page, client, pool).await?;
+ let post = PostForm::from_apub(&page, client, pool).await?;
let post_id = get_or_fetch_and_insert_remote_post(&post.ap_id, client, pool)
.await?
@@ -538,7 +529,7 @@ async fn receive_dislike_post(
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut page = dislike
+ let page = dislike
.dislike_props
.get_object_base_box()
.to_owned()
@@ -556,7 +547,7 @@ async fn receive_dislike_post(
insert_activity(user.id, dislike, false, pool).await?;
- let post = PostForm::from_apub(&mut page, client, pool).await?;
+ let post = PostForm::from_apub(&page, client, pool).await?;
let post_id = get_or_fetch_and_insert_remote_post(&post.ap_id, client, pool)
.await?
@@ -593,7 +584,7 @@ async fn receive_update_comment(
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut note = update
+ let note = update
.update_props
.get_object_base_box()
.to_owned()
@@ -611,7 +602,7 @@ async fn receive_update_comment(
insert_activity(user.id, update, false, pool).await?;
- let comment = CommentForm::from_apub(&mut note, client, pool).await?;
+ let comment = CommentForm::from_apub(&note, client, pool).await?;
let comment_id = get_or_fetch_and_insert_remote_comment(&comment.ap_id, client, pool)
.await?
@@ -652,7 +643,7 @@ async fn receive_like_comment(
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut note = like
+ let note = like
.like_props
.get_object_base_box()
.to_owned()
@@ -666,7 +657,7 @@ async fn receive_like_comment(
insert_activity(user.id, like, false, pool).await?;
- let comment = CommentForm::from_apub(&mut note, client, pool).await?;
+ let comment = CommentForm::from_apub(&note, client, pool).await?;
let comment_id = get_or_fetch_and_insert_remote_comment(&comment.ap_id, client, pool)
.await?
@@ -710,7 +701,7 @@ async fn receive_dislike_comment(
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut note = dislike
+ let note = dislike
.dislike_props
.get_object_base_box()
.to_owned()
@@ -728,7 +719,7 @@ async fn receive_dislike_comment(
insert_activity(user.id, dislike, false, pool).await?;
- let comment = CommentForm::from_apub(&mut note, client, pool).await?;
+ let comment = CommentForm::from_apub(&note, client, pool).await?;
let comment_id = get_or_fetch_and_insert_remote_comment(&comment.ap_id, client, pool)
.await?
@@ -778,7 +769,7 @@ async fn receive_delete_community(
.unwrap()
.to_string();
- let mut group = delete
+ let group = delete
.delete_props
.get_object_base_box()
.to_owned()
@@ -790,7 +781,7 @@ async fn receive_delete_community(
insert_activity(user.id, delete, false, pool).await?;
- let community_actor_id = CommunityForm::from_apub(&mut group, client, pool)
+ let community_actor_id = CommunityForm::from_apub(&group, client, pool)
.await?
.actor_id;
@@ -855,7 +846,7 @@ async fn receive_remove_community(
.unwrap()
.to_string();
- let mut group = remove
+ let group = remove
.remove_props
.get_object_base_box()
.to_owned()
@@ -867,7 +858,7 @@ async fn receive_remove_community(
insert_activity(mod_.id, remove, false, pool).await?;
- let community_actor_id = CommunityForm::from_apub(&mut group, client, pool)
+ let community_actor_id = CommunityForm::from_apub(&group, client, pool)
.await?
.actor_id;
@@ -932,7 +923,7 @@ async fn receive_delete_post(
.unwrap()
.to_string();
- let mut page = delete
+ let page = delete
.delete_props
.get_object_base_box()
.to_owned()
@@ -944,7 +935,7 @@ async fn receive_delete_post(
insert_activity(user.id, delete, false, pool).await?;
- let post_ap_id = PostForm::from_apub(&mut page, client, pool).await?.ap_id;
+ let post_ap_id = PostForm::from_apub(&page, client, pool).await?.ap_id;
let post = get_or_fetch_and_insert_remote_post(&post_ap_id, client, pool).await?;
@@ -998,7 +989,7 @@ async fn receive_remove_post(
.unwrap()
.to_string();
- let mut page = remove
+ let page = remove
.remove_props
.get_object_base_box()
.to_owned()
@@ -1010,7 +1001,7 @@ async fn receive_remove_post(
insert_activity(mod_.id, remove, false, pool).await?;
- let post_ap_id = PostForm::from_apub(&mut page, client, pool).await?.ap_id;
+ let post_ap_id = PostForm::from_apub(&page, client, pool).await?.ap_id;
let post = get_or_fetch_and_insert_remote_post(&post_ap_id, client, pool).await?;
@@ -1064,7 +1055,7 @@ async fn receive_delete_comment(
.unwrap()
.to_string();
- let mut note = delete
+ let note = delete
.delete_props
.get_object_base_box()
.to_owned()
@@ -1076,7 +1067,7 @@ async fn receive_delete_comment(
insert_activity(user.id, delete, false, pool).await?;
- let comment_ap_id = CommentForm::from_apub(&mut note, client, pool).await?.ap_id;
+ let comment_ap_id = CommentForm::from_apub(&note, client, pool).await?.ap_id;
let comment = get_or_fetch_and_insert_remote_comment(&comment_ap_id, client, pool).await?;
@@ -1132,7 +1123,7 @@ async fn receive_remove_comment(
.unwrap()
.to_string();
- let mut note = remove
+ let note = remove
.remove_props
.get_object_base_box()
.to_owned()
@@ -1144,7 +1135,7 @@ async fn receive_remove_comment(
insert_activity(mod_.id, remove, false, pool).await?;
- let comment_ap_id = CommentForm::from_apub(&mut note, client, pool).await?.ap_id;
+ let comment_ap_id = CommentForm::from_apub(&note, client, pool).await?.ap_id;
let comment = get_or_fetch_and_insert_remote_comment(&comment_ap_id, client, pool).await?;
@@ -1260,7 +1251,7 @@ async fn receive_undo_delete_comment(
.unwrap()
.to_string();
- let mut note = delete
+ let note = delete
.delete_props
.get_object_base_box()
.to_owned()
@@ -1272,7 +1263,7 @@ async fn receive_undo_delete_comment(
insert_activity(user.id, delete, false, pool).await?;
- let comment_ap_id = CommentForm::from_apub(&mut note, client, pool).await?.ap_id;
+ let comment_ap_id = CommentForm::from_apub(&note, client, pool).await?.ap_id;
let comment = get_or_fetch_and_insert_remote_comment(&comment_ap_id, client, pool).await?;
@@ -1328,7 +1319,7 @@ async fn receive_undo_remove_comment(
.unwrap()
.to_string();
- let mut note = remove
+ let note = remove
.remove_props
.get_object_base_box()
.to_owned()
@@ -1340,7 +1331,7 @@ async fn receive_undo_remove_comment(
insert_activity(mod_.id, remove, false, pool).await?;
- let comment_ap_id = CommentForm::from_apub(&mut note, client, pool).await?.ap_id;
+ let comment_ap_id = CommentForm::from_apub(&note, client, pool).await?.ap_id;
let comment = get_or_fetch_and_insert_remote_comment(&comment_ap_id, client, pool).await?;
@@ -1396,7 +1387,7 @@ async fn receive_undo_delete_post(
.unwrap()
.to_string();
- let mut page = delete
+ let page = delete
.delete_props
.get_object_base_box()
.to_owned()
@@ -1408,7 +1399,7 @@ async fn receive_undo_delete_post(
insert_activity(user.id, delete, false, pool).await?;
- let post_ap_id = PostForm::from_apub(&mut page, client, pool).await?.ap_id;
+ let post_ap_id = PostForm::from_apub(&page, client, pool).await?.ap_id;
let post = get_or_fetch_and_insert_remote_post(&post_ap_id, client, pool).await?;
@@ -1462,7 +1453,7 @@ async fn receive_undo_remove_post(
.unwrap()
.to_string();
- let mut page = remove
+ let page = remove
.remove_props
.get_object_base_box()
.to_owned()
@@ -1474,7 +1465,7 @@ async fn receive_undo_remove_post(
insert_activity(mod_.id, remove, false, pool).await?;
- let post_ap_id = PostForm::from_apub(&mut page, client, pool).await?.ap_id;
+ let post_ap_id = PostForm::from_apub(&page, client, pool).await?.ap_id;
let post = get_or_fetch_and_insert_remote_post(&post_ap_id, client, pool).await?;
@@ -1528,7 +1519,7 @@ async fn receive_undo_delete_community(
.unwrap()
.to_string();
- let mut group = delete
+ let group = delete
.delete_props
.get_object_base_box()
.to_owned()
@@ -1540,7 +1531,7 @@ async fn receive_undo_delete_community(
insert_activity(user.id, delete, false, pool).await?;
- let community_actor_id = CommunityForm::from_apub(&mut group, client, pool)
+ let community_actor_id = CommunityForm::from_apub(&group, client, pool)
.await?
.actor_id;
@@ -1605,7 +1596,7 @@ async fn receive_undo_remove_community(
.unwrap()
.to_string();
- let mut group = remove
+ let group = remove
.remove_props
.get_object_base_box()
.to_owned()
@@ -1617,7 +1608,7 @@ async fn receive_undo_remove_community(
insert_activity(mod_.id, remove, false, pool).await?;
- let community_actor_id = CommunityForm::from_apub(&mut group, client, pool)
+ let community_actor_id = CommunityForm::from_apub(&group, client, pool)
.await?
.actor_id;
@@ -1705,7 +1696,7 @@ async fn receive_undo_like_comment(
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut note = like
+ let note = like
.like_props
.get_object_base_box()
.to_owned()
@@ -1719,7 +1710,7 @@ async fn receive_undo_like_comment(
insert_activity(user.id, like, false, pool).await?;
- let comment = CommentForm::from_apub(&mut note, client, pool).await?;
+ let comment = CommentForm::from_apub(&note, client, pool).await?;
let comment_id = get_or_fetch_and_insert_remote_comment(&comment.ap_id, client, pool)
.await?
@@ -1759,7 +1750,7 @@ async fn receive_undo_like_post(
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut page = like
+ let page = like
.like_props
.get_object_base_box()
.to_owned()
@@ -1773,7 +1764,7 @@ async fn receive_undo_like_post(
insert_activity(user.id, like, false, pool).await?;
- let post = PostForm::from_apub(&mut page, client, pool).await?;
+ let post = PostForm::from_apub(&page, client, pool).await?;
let post_id = get_or_fetch_and_insert_remote_post(&post.ap_id, client, pool)
.await?