From 773a6d3beba2cf89eac75913078b40c4f5190dd4 Mon Sep 17 00:00:00 2001 From: dull b Date: Fri, 30 Jun 2023 06:56:12 +0000 Subject: [PATCH] Add blank lines under each line with `conn =` --- crates/api/src/comment/save.rs | 1 + crates/api/src/comment_report/create.rs | 1 + crates/api/src/comment_report/resolve.rs | 1 + crates/api/src/community/add_mod.rs | 1 + crates/api/src/community/ban.rs | 1 + crates/api/src/community/block.rs | 1 + crates/api/src/community/follow.rs | 1 + crates/api/src/community/hide.rs | 1 + crates/api/src/community/transfer.rs | 1 + crates/api/src/lib.rs | 1 + crates/api/src/local_user/add_admin.rs | 1 + crates/api/src/local_user/ban_person.rs | 1 + crates/api/src/local_user/block.rs | 1 + crates/api/src/local_user/change_password.rs | 1 + crates/api/src/local_user/change_password_after_reset.rs | 1 + crates/api/src/local_user/get_captcha.rs | 1 + crates/api/src/local_user/list_banned.rs | 1 + crates/api/src/local_user/login.rs | 1 + crates/api/src/local_user/notifications/list_mentions.rs | 1 + crates/api/src/local_user/notifications/list_replies.rs | 1 + crates/api/src/local_user/notifications/mark_all_read.rs | 1 + .../src/local_user/notifications/mark_mention_read.rs | 1 + .../api/src/local_user/notifications/mark_reply_read.rs | 1 + crates/api/src/local_user/notifications/unread_count.rs | 1 + crates/api/src/local_user/report_count.rs | 1 + crates/api/src/local_user/reset_password.rs | 1 + crates/api/src/local_user/save_settings.rs | 1 + crates/api/src/local_user/verify_email.rs | 1 + crates/api/src/post/feature.rs | 1 + crates/api/src/post/like.rs | 1 + crates/api/src/post/lock.rs | 1 + crates/api/src/post/mark_read.rs | 1 + crates/api/src/post/save.rs | 1 + crates/api/src/post_report/create.rs | 1 + crates/api/src/post_report/list.rs | 1 + crates/api/src/post_report/resolve.rs | 1 + crates/api/src/private_message/mark_read.rs | 1 + crates/api/src/private_message_report/create.rs | 1 + crates/api/src/private_message_report/list.rs | 1 + crates/api/src/private_message_report/resolve.rs | 1 + crates/api/src/site/federated_instances.rs | 1 + crates/api/src/site/leave_admin.rs | 1 + crates/api/src/site/mod_log.rs | 1 + crates/api/src/site/purge/comment.rs | 1 + crates/api/src/site/purge/community.rs | 1 + crates/api/src/site/purge/person.rs | 1 + crates/api/src/site/purge/post.rs | 1 + crates/api/src/site/registration_applications/approve.rs | 1 + crates/api/src/site/registration_applications/list.rs | 2 ++ .../src/site/registration_applications/unread_count.rs | 1 + crates/api_common/src/utils.rs | 1 + crates/api_crud/src/comment/create.rs | 1 + crates/api_crud/src/comment/delete.rs | 1 + crates/api_crud/src/comment/read.rs | 1 + crates/api_crud/src/comment/remove.rs | 1 + crates/api_crud/src/comment/update.rs | 1 + crates/api_crud/src/community/create.rs | 1 + crates/api_crud/src/community/delete.rs | 1 + crates/api_crud/src/community/list.rs | 2 ++ crates/api_crud/src/community/remove.rs | 1 + crates/api_crud/src/community/update.rs | 1 + crates/api_crud/src/custom_emoji/create.rs | 1 + crates/api_crud/src/custom_emoji/delete.rs | 1 + crates/api_crud/src/custom_emoji/update.rs | 1 + crates/api_crud/src/post/create.rs | 1 + crates/api_crud/src/post/delete.rs | 1 + crates/api_crud/src/post/read.rs | 1 + crates/api_crud/src/post/remove.rs | 1 + crates/api_crud/src/post/update.rs | 1 + crates/api_crud/src/private_message/create.rs | 1 + crates/api_crud/src/private_message/delete.rs | 1 + crates/api_crud/src/private_message/read.rs | 1 + crates/api_crud/src/private_message/update.rs | 1 + crates/api_crud/src/site/create.rs | 1 + crates/api_crud/src/site/read.rs | 1 + crates/api_crud/src/site/update.rs | 1 + crates/api_crud/src/user/create.rs | 1 + crates/apub/src/activities/block/block_user.rs | 1 + crates/apub/src/activities/block/mod.rs | 2 ++ crates/apub/src/activities/block/undo_block_user.rs | 2 ++ crates/apub/src/activities/community/collection_add.rs | 3 +++ .../apub/src/activities/community/collection_remove.rs | 1 + crates/apub/src/activities/community/lock_page.rs | 3 +++ crates/apub/src/activities/community/mod.rs | 3 ++- crates/apub/src/activities/community/report.rs | 1 + crates/apub/src/activities/community/update.rs | 3 +++ crates/apub/src/activities/create_or_update/comment.rs | 4 +++- crates/apub/src/activities/create_or_update/post.rs | 2 ++ .../src/activities/create_or_update/private_message.rs | 1 + crates/apub/src/activities/deletion/delete.rs | 1 + crates/apub/src/activities/deletion/delete_user.rs | 2 ++ crates/apub/src/activities/deletion/mod.rs | 8 ++++++++ crates/apub/src/activities/deletion/undo_delete.rs | 1 + crates/apub/src/activities/following/accept.rs | 1 + crates/apub/src/activities/following/follow.rs | 3 +++ crates/apub/src/activities/following/mod.rs | 1 + crates/apub/src/activities/following/undo_follow.rs | 1 + crates/apub/src/activities/mod.rs | 2 ++ crates/apub/src/activities/voting/mod.rs | 5 +++++ crates/apub/src/api/list_comments.rs | 2 ++ crates/apub/src/api/list_posts.rs | 2 ++ crates/apub/src/api/read_community.rs | 1 + crates/apub/src/api/read_person.rs | 3 +++ crates/apub/src/api/resolve_object.rs | 1 + crates/apub/src/api/search.rs | 2 ++ crates/apub/src/fetcher/mod.rs | 3 ++- crates/apub/src/fetcher/post_or_comment.rs | 1 + crates/apub/src/http/comment.rs | 1 + crates/apub/src/http/community.rs | 5 +++++ crates/apub/src/http/mod.rs | 1 + crates/apub/src/http/person.rs | 2 ++ crates/apub/src/http/post.rs | 1 + crates/apub/src/http/site.rs | 1 + crates/apub/src/mentions.rs | 1 + crates/apub/src/objects/comment.rs | 5 +++++ crates/apub/src/objects/community.rs | 4 ++++ crates/apub/src/objects/instance.rs | 1 + crates/apub/src/objects/post.rs | 9 +++++++-- .../src/protocol/activities/community/collection_add.rs | 1 + .../protocol/activities/community/collection_remove.rs | 1 + .../apub/src/protocol/activities/community/lock_page.rs | 1 + .../src/protocol/activities/create_or_update/note.rs | 1 + crates/apub/src/protocol/activities/deletion/delete.rs | 1 + crates/apub/src/protocol/collections/group_followers.rs | 1 + crates/apub/src/protocol/objects/group.rs | 1 + crates/apub/src/protocol/objects/note.rs | 4 +++- crates/db_schema/src/impls/actor_language.rs | 2 ++ crates/db_schema/src/impls/federation_allowlist.rs | 1 + crates/db_schema/src/impls/person.rs | 1 + crates/db_schema/src/utils.rs | 1 + crates/db_views/src/comment_view.rs | 3 +++ crates/db_views/src/post_report_view.rs | 1 + crates/db_views/src/post_view.rs | 6 ++++++ crates/db_views/src/private_message_report_view.rs | 1 + crates/db_views/src/private_message_view.rs | 1 + crates/db_views/src/registration_application_view.rs | 1 + src/scheduled_tasks.rs | 7 +++++++ 137 files changed, 206 insertions(+), 6 deletions(-) diff --git a/crates/api/src/comment/save.rs b/crates/api/src/comment/save.rs index 6b7d67352..9545b38a9 100644 --- a/crates/api/src/comment/save.rs +++ b/crates/api/src/comment/save.rs @@ -19,6 +19,7 @@ impl Perform for SaveComment { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &SaveComment = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/comment_report/create.rs b/crates/api/src/comment_report/create.rs index e04de88f6..d910c6789 100644 --- a/crates/api/src/comment_report/create.rs +++ b/crates/api/src/comment_report/create.rs @@ -26,6 +26,7 @@ impl Perform for CreateCommentReport { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let data: &CreateCommentReport = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_site = LocalSite::read(&mut conn).await?; diff --git a/crates/api/src/comment_report/resolve.rs b/crates/api/src/comment_report/resolve.rs index 41e62f141..e11497385 100644 --- a/crates/api/src/comment_report/resolve.rs +++ b/crates/api/src/comment_report/resolve.rs @@ -20,6 +20,7 @@ impl Perform for ResolveCommentReport { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let data: &ResolveCommentReport = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/community/add_mod.rs b/crates/api/src/community/add_mod.rs index 4702f9261..8e113e538 100644 --- a/crates/api/src/community/add_mod.rs +++ b/crates/api/src/community/add_mod.rs @@ -25,6 +25,7 @@ impl Perform for AddModToCommunity { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let data: &AddModToCommunity = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/community/ban.rs b/crates/api/src/community/ban.rs index fbb80ed50..797ae34af 100644 --- a/crates/api/src/community/ban.rs +++ b/crates/api/src/community/ban.rs @@ -33,6 +33,7 @@ impl Perform for BanFromCommunity { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let data: &BanFromCommunity = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/community/block.rs b/crates/api/src/community/block.rs index ec8dfd739..e488c3dd2 100644 --- a/crates/api/src/community/block.rs +++ b/crates/api/src/community/block.rs @@ -25,6 +25,7 @@ impl Perform for BlockCommunity { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let data: &BlockCommunity = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/community/follow.rs b/crates/api/src/community/follow.rs index bb998dcc3..ab3409066 100644 --- a/crates/api/src/community/follow.rs +++ b/crates/api/src/community/follow.rs @@ -22,6 +22,7 @@ impl Perform for FollowCommunity { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &FollowCommunity = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/community/hide.rs b/crates/api/src/community/hide.rs index 54cb60326..611347b7c 100644 --- a/crates/api/src/community/hide.rs +++ b/crates/api/src/community/hide.rs @@ -22,6 +22,7 @@ impl Perform for HideCommunity { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &HideCommunity = self; // Verify its a admin (only admin can hide or unhide it) diff --git a/crates/api/src/community/transfer.rs b/crates/api/src/community/transfer.rs index 17e3feddf..874c9c11a 100644 --- a/crates/api/src/community/transfer.rs +++ b/crates/api/src/community/transfer.rs @@ -28,6 +28,7 @@ impl Perform for TransferCommunity { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let data: &TransferCommunity = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/lib.rs b/crates/api/src/lib.rs index 632e2c3bd..a3d42c046 100644 --- a/crates/api/src/lib.rs +++ b/crates/api/src/lib.rs @@ -70,6 +70,7 @@ mod tests { #[serial] async fn test_should_not_validate_user_token_after_password_change() { let conn = &mut build_db_conn_for_tests().await; + let secret = Secret::init(conn).await.unwrap(); let settings = &SETTINGS.to_owned(); diff --git a/crates/api/src/local_user/add_admin.rs b/crates/api/src/local_user/add_admin.rs index 23a1c53db..4b6988e94 100644 --- a/crates/api/src/local_user/add_admin.rs +++ b/crates/api/src/local_user/add_admin.rs @@ -22,6 +22,7 @@ impl Perform for AddAdmin { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &AddAdmin = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/local_user/ban_person.rs b/crates/api/src/local_user/ban_person.rs index 425cc588f..ac9c92634 100644 --- a/crates/api/src/local_user/ban_person.rs +++ b/crates/api/src/local_user/ban_person.rs @@ -25,6 +25,7 @@ impl Perform for BanPerson { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &BanPerson = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/local_user/block.rs b/crates/api/src/local_user/block.rs index ea30202d8..8f1566489 100644 --- a/crates/api/src/local_user/block.rs +++ b/crates/api/src/local_user/block.rs @@ -19,6 +19,7 @@ impl Perform for BlockPerson { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &BlockPerson = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/local_user/change_password.rs b/crates/api/src/local_user/change_password.rs index 64255b224..3ce3d7253 100644 --- a/crates/api/src/local_user/change_password.rs +++ b/crates/api/src/local_user/change_password.rs @@ -16,6 +16,7 @@ impl Perform for ChangePassword { #[tracing::instrument(skip(self, context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &ChangePassword = self; let local_user_view = local_user_view_from_jwt(data.auth.as_ref(), context).await?; diff --git a/crates/api/src/local_user/change_password_after_reset.rs b/crates/api/src/local_user/change_password_after_reset.rs index 2203c33a7..ac216335b 100644 --- a/crates/api/src/local_user/change_password_after_reset.rs +++ b/crates/api/src/local_user/change_password_after_reset.rs @@ -19,6 +19,7 @@ impl Perform for PasswordChangeAfterReset { #[tracing::instrument(skip(self, context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &PasswordChangeAfterReset = self; // Fetch the user_id from the token diff --git a/crates/api/src/local_user/get_captcha.rs b/crates/api/src/local_user/get_captcha.rs index 45e16bcee..f45735834 100644 --- a/crates/api/src/local_user/get_captcha.rs +++ b/crates/api/src/local_user/get_captcha.rs @@ -18,6 +18,7 @@ impl Perform for GetCaptcha { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let local_site = LocalSite::read(&mut conn).await?; if !local_site.captcha_enabled { diff --git a/crates/api/src/local_user/list_banned.rs b/crates/api/src/local_user/list_banned.rs index 47ce5bc84..88c909144 100644 --- a/crates/api/src/local_user/list_banned.rs +++ b/crates/api/src/local_user/list_banned.rs @@ -14,6 +14,7 @@ impl Perform for GetBannedPersons { async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &GetBannedPersons = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/local_user/login.rs b/crates/api/src/local_user/login.rs index a188ddb19..8be321476 100644 --- a/crates/api/src/local_user/login.rs +++ b/crates/api/src/local_user/login.rs @@ -16,6 +16,7 @@ impl Perform for Login { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &Login = self; let site_view = SiteView::read_local(&mut conn).await?; diff --git a/crates/api/src/local_user/notifications/list_mentions.rs b/crates/api/src/local_user/notifications/list_mentions.rs index 7b6d9b6cf..31b47f830 100644 --- a/crates/api/src/local_user/notifications/list_mentions.rs +++ b/crates/api/src/local_user/notifications/list_mentions.rs @@ -28,6 +28,7 @@ impl Perform for GetPersonMentions { let show_bot_accounts = Some(local_user_view.local_user.show_bot_accounts); let mut conn = context.conn().await?; + let mentions = PersonMentionQuery::builder() .conn(&mut conn) .recipient_id(person_id) diff --git a/crates/api/src/local_user/notifications/list_replies.rs b/crates/api/src/local_user/notifications/list_replies.rs index bb427c4e4..f328fca5d 100644 --- a/crates/api/src/local_user/notifications/list_replies.rs +++ b/crates/api/src/local_user/notifications/list_replies.rs @@ -25,6 +25,7 @@ impl Perform for GetReplies { let show_bot_accounts = Some(local_user_view.local_user.show_bot_accounts); let mut conn = context.conn().await?; + let replies = CommentReplyQuery::builder() .conn(&mut conn) .recipient_id(person_id) diff --git a/crates/api/src/local_user/notifications/mark_all_read.rs b/crates/api/src/local_user/notifications/mark_all_read.rs index 766515330..8d86eeb48 100644 --- a/crates/api/src/local_user/notifications/mark_all_read.rs +++ b/crates/api/src/local_user/notifications/mark_all_read.rs @@ -19,6 +19,7 @@ impl Perform for MarkAllAsRead { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &MarkAllAsRead = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let person_id = local_user_view.person.id; diff --git a/crates/api/src/local_user/notifications/mark_mention_read.rs b/crates/api/src/local_user/notifications/mark_mention_read.rs index 4dc31cc03..62d1ddbad 100644 --- a/crates/api/src/local_user/notifications/mark_mention_read.rs +++ b/crates/api/src/local_user/notifications/mark_mention_read.rs @@ -22,6 +22,7 @@ impl Perform for MarkPersonMentionAsRead { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let data: &MarkPersonMentionAsRead = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/local_user/notifications/mark_reply_read.rs b/crates/api/src/local_user/notifications/mark_reply_read.rs index 4de8524d8..0c5b07515 100644 --- a/crates/api/src/local_user/notifications/mark_reply_read.rs +++ b/crates/api/src/local_user/notifications/mark_reply_read.rs @@ -22,6 +22,7 @@ impl Perform for MarkCommentReplyAsRead { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let data = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/local_user/notifications/unread_count.rs b/crates/api/src/local_user/notifications/unread_count.rs index ab7c59d7c..e7a2348ca 100644 --- a/crates/api/src/local_user/notifications/unread_count.rs +++ b/crates/api/src/local_user/notifications/unread_count.rs @@ -16,6 +16,7 @@ impl Perform for GetUnreadCount { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/local_user/report_count.rs b/crates/api/src/local_user/report_count.rs index e130a302b..6faa13d94 100644 --- a/crates/api/src/local_user/report_count.rs +++ b/crates/api/src/local_user/report_count.rs @@ -18,6 +18,7 @@ impl Perform for GetReportCount { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let data: &GetReportCount = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/local_user/reset_password.rs b/crates/api/src/local_user/reset_password.rs index 29411cae0..d04806700 100644 --- a/crates/api/src/local_user/reset_password.rs +++ b/crates/api/src/local_user/reset_password.rs @@ -19,6 +19,7 @@ impl Perform for PasswordReset { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let data: &PasswordReset = self; // Fetch that email diff --git a/crates/api/src/local_user/save_settings.rs b/crates/api/src/local_user/save_settings.rs index 1356e895f..7b7c53c76 100644 --- a/crates/api/src/local_user/save_settings.rs +++ b/crates/api/src/local_user/save_settings.rs @@ -34,6 +34,7 @@ impl Perform for SaveUserSettings { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &SaveUserSettings = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let site_view = SiteView::read_local(&mut conn).await?; diff --git a/crates/api/src/local_user/verify_email.rs b/crates/api/src/local_user/verify_email.rs index 2d9006f22..9f7db3991 100644 --- a/crates/api/src/local_user/verify_email.rs +++ b/crates/api/src/local_user/verify_email.rs @@ -19,6 +19,7 @@ impl Perform for VerifyEmail { async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let token = self.token.clone(); let verification = EmailVerification::read_for_token(&mut conn, &token) .await diff --git a/crates/api/src/post/feature.rs b/crates/api/src/post/feature.rs index 50b583010..f42c1eb62 100644 --- a/crates/api/src/post/feature.rs +++ b/crates/api/src/post/feature.rs @@ -29,6 +29,7 @@ impl Perform for FeaturePost { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &FeaturePost = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/post/like.rs b/crates/api/src/post/like.rs index 3ba8747bc..8d07cba91 100644 --- a/crates/api/src/post/like.rs +++ b/crates/api/src/post/like.rs @@ -28,6 +28,7 @@ impl Perform for CreatePostLike { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &CreatePostLike = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_site = LocalSite::read(&mut conn).await?; diff --git a/crates/api/src/post/lock.rs b/crates/api/src/post/lock.rs index b163be7d3..cea73318e 100644 --- a/crates/api/src/post/lock.rs +++ b/crates/api/src/post/lock.rs @@ -27,6 +27,7 @@ impl Perform for LockPost { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &LockPost = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/post/mark_read.rs b/crates/api/src/post/mark_read.rs index 076c76745..ba68881a8 100644 --- a/crates/api/src/post/mark_read.rs +++ b/crates/api/src/post/mark_read.rs @@ -15,6 +15,7 @@ impl Perform for MarkPostAsRead { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/post/save.rs b/crates/api/src/post/save.rs index 53d9de66a..307f4e9ff 100644 --- a/crates/api/src/post/save.rs +++ b/crates/api/src/post/save.rs @@ -19,6 +19,7 @@ impl Perform for SavePost { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &SavePost = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/post_report/create.rs b/crates/api/src/post_report/create.rs index 400a4f325..d81cf412e 100644 --- a/crates/api/src/post_report/create.rs +++ b/crates/api/src/post_report/create.rs @@ -23,6 +23,7 @@ impl Perform for CreatePostReport { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &CreatePostReport = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_site = LocalSite::read(&mut conn).await?; diff --git a/crates/api/src/post_report/list.rs b/crates/api/src/post_report/list.rs index 3a8688075..1b13d5f27 100644 --- a/crates/api/src/post_report/list.rs +++ b/crates/api/src/post_report/list.rs @@ -30,6 +30,7 @@ impl Perform for ListPostReports { let page = data.page; let limit = data.limit; let mut conn = context.conn().await?; + let post_reports = PostReportQuery::builder() .conn(&mut conn) .my_person_id(person_id) diff --git a/crates/api/src/post_report/resolve.rs b/crates/api/src/post_report/resolve.rs index 62c649a1a..c2cdccd94 100644 --- a/crates/api/src/post_report/resolve.rs +++ b/crates/api/src/post_report/resolve.rs @@ -17,6 +17,7 @@ impl Perform for ResolvePostReport { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &ResolvePostReport = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/private_message/mark_read.rs b/crates/api/src/private_message/mark_read.rs index 893fca0d2..bb3dd70c1 100644 --- a/crates/api/src/private_message/mark_read.rs +++ b/crates/api/src/private_message/mark_read.rs @@ -22,6 +22,7 @@ impl Perform for MarkPrivateMessageAsRead { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let data: &MarkPrivateMessageAsRead = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/private_message_report/create.rs b/crates/api/src/private_message_report/create.rs index 6305aa649..56d36ea09 100644 --- a/crates/api/src/private_message_report/create.rs +++ b/crates/api/src/private_message_report/create.rs @@ -23,6 +23,7 @@ impl Perform for CreatePrivateMessageReport { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let local_user_view = local_user_view_from_jwt(&self.auth, context).await?; let local_site = LocalSite::read(&mut conn).await?; diff --git a/crates/api/src/private_message_report/list.rs b/crates/api/src/private_message_report/list.rs index 16e358b40..a5ee76f85 100644 --- a/crates/api/src/private_message_report/list.rs +++ b/crates/api/src/private_message_report/list.rs @@ -22,6 +22,7 @@ impl Perform for ListPrivateMessageReports { let page = self.page; let limit = self.limit; let mut conn = context.conn().await?; + let private_message_reports = PrivateMessageReportQuery::builder() .conn(&mut conn) .unresolved_only(unresolved_only) diff --git a/crates/api/src/private_message_report/resolve.rs b/crates/api/src/private_message_report/resolve.rs index 0c8f5893d..4f461a366 100644 --- a/crates/api/src/private_message_report/resolve.rs +++ b/crates/api/src/private_message_report/resolve.rs @@ -16,6 +16,7 @@ impl Perform for ResolvePrivateMessageReport { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let local_user_view = local_user_view_from_jwt(&self.auth, context).await?; is_admin(&local_user_view)?; diff --git a/crates/api/src/site/federated_instances.rs b/crates/api/src/site/federated_instances.rs index 08ba092e3..6c2c18c0e 100644 --- a/crates/api/src/site/federated_instances.rs +++ b/crates/api/src/site/federated_instances.rs @@ -15,6 +15,7 @@ impl Perform for GetFederatedInstances { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let site_view = SiteView::read_local(&mut conn).await?; let federated_instances = build_federated_instances(&site_view.local_site, context.pool()).await?; diff --git a/crates/api/src/site/leave_admin.rs b/crates/api/src/site/leave_admin.rs index eb611ac21..8a62ccf04 100644 --- a/crates/api/src/site/leave_admin.rs +++ b/crates/api/src/site/leave_admin.rs @@ -26,6 +26,7 @@ impl Perform for LeaveAdmin { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &LeaveAdmin = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/site/mod_log.rs b/crates/api/src/site/mod_log.rs index bfa904f91..7f6dad5a6 100644 --- a/crates/api/src/site/mod_log.rs +++ b/crates/api/src/site/mod_log.rs @@ -38,6 +38,7 @@ impl Perform for GetModlog { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &GetModlog = self; let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await; diff --git a/crates/api/src/site/purge/comment.rs b/crates/api/src/site/purge/comment.rs index 50ee4f230..c619aa56b 100644 --- a/crates/api/src/site/purge/comment.rs +++ b/crates/api/src/site/purge/comment.rs @@ -21,6 +21,7 @@ impl Perform for PurgeComment { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &Self = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/site/purge/community.rs b/crates/api/src/site/purge/community.rs index 949482358..112751ab8 100644 --- a/crates/api/src/site/purge/community.rs +++ b/crates/api/src/site/purge/community.rs @@ -22,6 +22,7 @@ impl Perform for PurgeCommunity { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &Self = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/site/purge/person.rs b/crates/api/src/site/purge/person.rs index 885f4b1a3..76c6b95da 100644 --- a/crates/api/src/site/purge/person.rs +++ b/crates/api/src/site/purge/person.rs @@ -22,6 +22,7 @@ impl Perform for PurgePerson { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &Self = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/site/purge/post.rs b/crates/api/src/site/purge/post.rs index 740c7abc3..5036d104d 100644 --- a/crates/api/src/site/purge/post.rs +++ b/crates/api/src/site/purge/post.rs @@ -22,6 +22,7 @@ impl Perform for PurgePost { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &Self = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/site/registration_applications/approve.rs b/crates/api/src/site/registration_applications/approve.rs index 3aeaea9ba..95011cb54 100644 --- a/crates/api/src/site/registration_applications/approve.rs +++ b/crates/api/src/site/registration_applications/approve.rs @@ -22,6 +22,7 @@ impl Perform for ApproveRegistrationApplication { async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api/src/site/registration_applications/list.rs b/crates/api/src/site/registration_applications/list.rs index e5a25343e..cbbb92743 100644 --- a/crates/api/src/site/registration_applications/list.rs +++ b/crates/api/src/site/registration_applications/list.rs @@ -16,6 +16,7 @@ impl Perform for ListRegistrationApplications { async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_site = LocalSite::read(&mut conn).await?; @@ -29,6 +30,7 @@ impl Perform for ListRegistrationApplications { let page = data.page; let limit = data.limit; let mut conn = context.conn().await?; + let registration_applications = RegistrationApplicationQuery::builder() .conn(&mut conn) .unread_only(unread_only) diff --git a/crates/api/src/site/registration_applications/unread_count.rs b/crates/api/src/site/registration_applications/unread_count.rs index 981dc2604..68b95e52d 100644 --- a/crates/api/src/site/registration_applications/unread_count.rs +++ b/crates/api/src/site/registration_applications/unread_count.rs @@ -15,6 +15,7 @@ impl Perform for GetUnreadRegistrationApplicationCount { async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_site = LocalSite::read(&mut conn).await?; diff --git a/crates/api_common/src/utils.rs b/crates/api_common/src/utils.rs index 29f307922..3ce2fd4af 100644 --- a/crates/api_common/src/utils.rs +++ b/crates/api_common/src/utils.rs @@ -139,6 +139,7 @@ pub async fn local_user_view_from_jwt( context: &LemmyContext, ) -> Result { let mut conn = context.conn().await?; + let claims = Claims::decode(jwt, &context.secret().jwt_secret) .map_err(|e| e.with_message("not_logged_in"))? .claims; diff --git a/crates/api_crud/src/comment/create.rs b/crates/api_crud/src/comment/create.rs index 5bb1e244c..b0c3ef970 100644 --- a/crates/api_crud/src/comment/create.rs +++ b/crates/api_crud/src/comment/create.rs @@ -42,6 +42,7 @@ impl PerformCrud for CreateComment { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &CreateComment = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_site = LocalSite::read(&mut conn).await?; diff --git a/crates/api_crud/src/comment/delete.rs b/crates/api_crud/src/comment/delete.rs index 5115cb593..13fc39af2 100644 --- a/crates/api_crud/src/comment/delete.rs +++ b/crates/api_crud/src/comment/delete.rs @@ -23,6 +23,7 @@ impl PerformCrud for DeleteComment { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &DeleteComment = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api_crud/src/comment/read.rs b/crates/api_crud/src/comment/read.rs index 210b74b0a..e974ba5c7 100644 --- a/crates/api_crud/src/comment/read.rs +++ b/crates/api_crud/src/comment/read.rs @@ -16,6 +16,7 @@ impl PerformCrud for GetComment { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data = self; let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await; let local_site = LocalSite::read(&mut conn).await?; diff --git a/crates/api_crud/src/comment/remove.rs b/crates/api_crud/src/comment/remove.rs index 56719922a..b0964832f 100644 --- a/crates/api_crud/src/comment/remove.rs +++ b/crates/api_crud/src/comment/remove.rs @@ -24,6 +24,7 @@ impl PerformCrud for RemoveComment { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &RemoveComment = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api_crud/src/comment/update.rs b/crates/api_crud/src/comment/update.rs index 6db62295b..e9ee195c2 100644 --- a/crates/api_crud/src/comment/update.rs +++ b/crates/api_crud/src/comment/update.rs @@ -32,6 +32,7 @@ impl PerformCrud for EditComment { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &EditComment = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_site = LocalSite::read(&mut conn).await?; diff --git a/crates/api_crud/src/community/create.rs b/crates/api_crud/src/community/create.rs index f9e2b9c3c..89ee06dec 100644 --- a/crates/api_crud/src/community/create.rs +++ b/crates/api_crud/src/community/create.rs @@ -47,6 +47,7 @@ impl PerformCrud for CreateCommunity { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &CreateCommunity = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let site_view = SiteView::read_local(&mut conn).await?; diff --git a/crates/api_crud/src/community/delete.rs b/crates/api_crud/src/community/delete.rs index 84e555de6..414d52384 100644 --- a/crates/api_crud/src/community/delete.rs +++ b/crates/api_crud/src/community/delete.rs @@ -20,6 +20,7 @@ impl PerformCrud for DeleteCommunity { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &DeleteCommunity = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api_crud/src/community/list.rs b/crates/api_crud/src/community/list.rs index d00db436b..0727f4cf2 100644 --- a/crates/api_crud/src/community/list.rs +++ b/crates/api_crud/src/community/list.rs @@ -19,6 +19,7 @@ impl PerformCrud for ListCommunities { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let data: &ListCommunities = self; let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await; let local_site = LocalSite::read(&mut conn).await?; @@ -33,6 +34,7 @@ impl PerformCrud for ListCommunities { let limit = data.limit; let local_user = local_user_view.map(|l| l.local_user); let mut conn = context.conn().await?; + let communities = CommunityQuery::builder() .conn(&mut conn) .listing_type(listing_type) diff --git a/crates/api_crud/src/community/remove.rs b/crates/api_crud/src/community/remove.rs index d3c7cae46..4f94897e2 100644 --- a/crates/api_crud/src/community/remove.rs +++ b/crates/api_crud/src/community/remove.rs @@ -22,6 +22,7 @@ impl PerformCrud for RemoveCommunity { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &RemoveCommunity = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api_crud/src/community/update.rs b/crates/api_crud/src/community/update.rs index 9cd60c05a..8e01e1418 100644 --- a/crates/api_crud/src/community/update.rs +++ b/crates/api_crud/src/community/update.rs @@ -29,6 +29,7 @@ impl PerformCrud for EditCommunity { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &EditCommunity = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_site = LocalSite::read(&mut conn).await?; diff --git a/crates/api_crud/src/custom_emoji/create.rs b/crates/api_crud/src/custom_emoji/create.rs index 8df6be0b6..d1b8547e9 100644 --- a/crates/api_crud/src/custom_emoji/create.rs +++ b/crates/api_crud/src/custom_emoji/create.rs @@ -20,6 +20,7 @@ impl PerformCrud for CreateCustomEmoji { #[tracing::instrument(skip(self, context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &CreateCustomEmoji = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api_crud/src/custom_emoji/delete.rs b/crates/api_crud/src/custom_emoji/delete.rs index ac9752f68..c2021c0db 100644 --- a/crates/api_crud/src/custom_emoji/delete.rs +++ b/crates/api_crud/src/custom_emoji/delete.rs @@ -18,6 +18,7 @@ impl PerformCrud for DeleteCustomEmoji { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let data: &DeleteCustomEmoji = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api_crud/src/custom_emoji/update.rs b/crates/api_crud/src/custom_emoji/update.rs index 1d0e6416d..ddc3ae2fb 100644 --- a/crates/api_crud/src/custom_emoji/update.rs +++ b/crates/api_crud/src/custom_emoji/update.rs @@ -20,6 +20,7 @@ impl PerformCrud for EditCustomEmoji { #[tracing::instrument(skip(self, context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &EditCustomEmoji = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api_crud/src/post/create.rs b/crates/api_crud/src/post/create.rs index a7b5bdd82..75f1cf787 100644 --- a/crates/api_crud/src/post/create.rs +++ b/crates/api_crud/src/post/create.rs @@ -45,6 +45,7 @@ impl PerformCrud for CreatePost { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &CreatePost = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_site = LocalSite::read(&mut conn).await?; diff --git a/crates/api_crud/src/post/delete.rs b/crates/api_crud/src/post/delete.rs index 1206023de..6a1117502 100644 --- a/crates/api_crud/src/post/delete.rs +++ b/crates/api_crud/src/post/delete.rs @@ -19,6 +19,7 @@ impl PerformCrud for DeletePost { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &DeletePost = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api_crud/src/post/read.rs b/crates/api_crud/src/post/read.rs index d746dbd61..f96973838 100644 --- a/crates/api_crud/src/post/read.rs +++ b/crates/api_crud/src/post/read.rs @@ -26,6 +26,7 @@ impl PerformCrud for GetPost { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &GetPost = self; let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await; let local_site = LocalSite::read(&mut conn).await?; diff --git a/crates/api_crud/src/post/remove.rs b/crates/api_crud/src/post/remove.rs index d4cb193c4..71a9886ab 100644 --- a/crates/api_crud/src/post/remove.rs +++ b/crates/api_crud/src/post/remove.rs @@ -22,6 +22,7 @@ impl PerformCrud for RemovePost { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &RemovePost = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api_crud/src/post/update.rs b/crates/api_crud/src/post/update.rs index ad25e881e..053f7f936 100644 --- a/crates/api_crud/src/post/update.rs +++ b/crates/api_crud/src/post/update.rs @@ -31,6 +31,7 @@ impl PerformCrud for EditPost { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &EditPost = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_site = LocalSite::read(&mut conn).await?; diff --git a/crates/api_crud/src/private_message/create.rs b/crates/api_crud/src/private_message/create.rs index ca41b65b6..6f35a0ca2 100644 --- a/crates/api_crud/src/private_message/create.rs +++ b/crates/api_crud/src/private_message/create.rs @@ -36,6 +36,7 @@ impl PerformCrud for CreatePrivateMessage { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let data: &CreatePrivateMessage = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_site = LocalSite::read(&mut conn).await?; diff --git a/crates/api_crud/src/private_message/delete.rs b/crates/api_crud/src/private_message/delete.rs index 35e4b2158..b167d1d43 100644 --- a/crates/api_crud/src/private_message/delete.rs +++ b/crates/api_crud/src/private_message/delete.rs @@ -22,6 +22,7 @@ impl PerformCrud for DeletePrivateMessage { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let data: &DeletePrivateMessage = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api_crud/src/private_message/read.rs b/crates/api_crud/src/private_message/read.rs index ddd3e83a1..d6ef0afb1 100644 --- a/crates/api_crud/src/private_message/read.rs +++ b/crates/api_crud/src/private_message/read.rs @@ -18,6 +18,7 @@ impl PerformCrud for GetPrivateMessages { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let data: &GetPrivateMessages = self; let local_user_view = local_user_view_from_jwt(data.auth.as_ref(), context).await?; let person_id = local_user_view.person.id; diff --git a/crates/api_crud/src/private_message/update.rs b/crates/api_crud/src/private_message/update.rs index 064c33bc9..497c176ff 100644 --- a/crates/api_crud/src/private_message/update.rs +++ b/crates/api_crud/src/private_message/update.rs @@ -29,6 +29,7 @@ impl PerformCrud for EditPrivateMessage { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let data: &EditPrivateMessage = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_site = LocalSite::read(&mut conn).await?; diff --git a/crates/api_crud/src/site/create.rs b/crates/api_crud/src/site/create.rs index ed5c86067..5d840ceda 100644 --- a/crates/api_crud/src/site/create.rs +++ b/crates/api_crud/src/site/create.rs @@ -48,6 +48,7 @@ impl PerformCrud for CreateSite { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &CreateSite = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; diff --git a/crates/api_crud/src/site/read.rs b/crates/api_crud/src/site/read.rs index 835b569e6..eff53a344 100644 --- a/crates/api_crud/src/site/read.rs +++ b/crates/api_crud/src/site/read.rs @@ -31,6 +31,7 @@ impl PerformCrud for GetSite { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &GetSite = self; let site_view = SiteView::read_local(&mut conn).await?; diff --git a/crates/api_crud/src/site/update.rs b/crates/api_crud/src/site/update.rs index 377e38cd3..1a16c2320 100644 --- a/crates/api_crud/src/site/update.rs +++ b/crates/api_crud/src/site/update.rs @@ -45,6 +45,7 @@ impl PerformCrud for EditSite { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &EditSite = self; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let site_view = SiteView::read_local(&mut conn).await?; diff --git a/crates/api_crud/src/user/create.rs b/crates/api_crud/src/user/create.rs index ab00149d4..ddf4855c1 100644 --- a/crates/api_crud/src/user/create.rs +++ b/crates/api_crud/src/user/create.rs @@ -44,6 +44,7 @@ impl PerformCrud for Register { #[tracing::instrument(skip(self, context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &Register = self; let site_view = SiteView::read_local(&mut conn).await?; diff --git a/crates/apub/src/activities/block/block_user.rs b/crates/apub/src/activities/block/block_user.rs index 3064ab85c..5714d9676 100644 --- a/crates/apub/src/activities/block/block_user.rs +++ b/crates/apub/src/activities/block/block_user.rs @@ -152,6 +152,7 @@ impl ActivityHandler for BlockUser { #[tracing::instrument(skip_all)] async fn receive(self, context: &Data) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + insert_activity(&self.id, &self, false, false, context).await?; let expires = self.expires.map(|u| u.naive_local()); let mod_person = self.actor.dereference(context).await?; diff --git a/crates/apub/src/activities/block/mod.rs b/crates/apub/src/activities/block/mod.rs index be03751a6..2639ff05d 100644 --- a/crates/apub/src/activities/block/mod.rs +++ b/crates/apub/src/activities/block/mod.rs @@ -139,6 +139,7 @@ impl SendActivity for BanPerson { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let person = Person::read(&mut conn, request.person_id).await?; let site = SiteOrCommunity::Site(SiteView::read_local(&mut conn).await?.site.into()); @@ -183,6 +184,7 @@ impl SendActivity for BanFromCommunity { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let community: ApubCommunity = Community::read(&mut conn, request.community_id) .await? diff --git a/crates/apub/src/activities/block/undo_block_user.rs b/crates/apub/src/activities/block/undo_block_user.rs index a5a6f98e9..1dac5a0da 100644 --- a/crates/apub/src/activities/block/undo_block_user.rs +++ b/crates/apub/src/activities/block/undo_block_user.rs @@ -39,6 +39,7 @@ impl UndoBlockUser { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let block = BlockUser::new(target, user, mod_, None, reason, None, context).await?; let audience = if let SiteOrCommunity::Community(c) = target { Some(c.id().into()) @@ -98,6 +99,7 @@ impl ActivityHandler for UndoBlockUser { #[tracing::instrument(skip_all)] async fn receive(self, context: &Data) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + insert_activity(&self.id, &self, false, false, context).await?; let expires = self.object.expires.map(|u| u.naive_local()); let mod_person = self.actor.dereference(context).await?; diff --git a/crates/apub/src/activities/community/collection_add.rs b/crates/apub/src/activities/community/collection_add.rs index 858ffff0c..e6dcc6724 100644 --- a/crates/apub/src/activities/community/collection_add.rs +++ b/crates/apub/src/activities/community/collection_add.rs @@ -118,6 +118,7 @@ impl ActivityHandler for CollectionAdd { #[tracing::instrument(skip_all)] async fn receive(self, context: &Data) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + insert_activity(&self.id, &self, false, false, context).await?; let (community, collection_type) = Community::get_by_collection_url(&mut conn, &self.target.into()).await?; @@ -175,6 +176,7 @@ impl SendActivity for AddModToCommunity { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let community: ApubCommunity = Community::read(&mut conn, request.community_id) .await? @@ -210,6 +212,7 @@ impl SendActivity for FeaturePost { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let community = Community::read(&mut conn, response.post_view.community.id) .await? diff --git a/crates/apub/src/activities/community/collection_remove.rs b/crates/apub/src/activities/community/collection_remove.rs index 9502db7c8..8fdbfd727 100644 --- a/crates/apub/src/activities/community/collection_remove.rs +++ b/crates/apub/src/activities/community/collection_remove.rs @@ -111,6 +111,7 @@ impl ActivityHandler for CollectionRemove { #[tracing::instrument(skip_all)] async fn receive(self, context: &Data) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + insert_activity(&self.id, &self, false, false, context).await?; let (community, collection_type) = Community::get_by_collection_url(&mut conn, &self.target.into()).await?; diff --git a/crates/apub/src/activities/community/lock_page.rs b/crates/apub/src/activities/community/lock_page.rs index 2e7c1839e..7c542cc3c 100644 --- a/crates/apub/src/activities/community/lock_page.rs +++ b/crates/apub/src/activities/community/lock_page.rs @@ -59,6 +59,7 @@ impl ActivityHandler for LockPage { async fn receive(self, context: &Data) -> Result<(), Self::Error> { let mut conn = context.conn().await?; + let form = PostUpdateForm::builder().locked(Some(true)).build(); let post = self.object.dereference(context).await?; Post::update(&mut conn, post.id, &form).await?; @@ -96,6 +97,7 @@ impl ActivityHandler for UndoLockPage { async fn receive(self, context: &Data) -> Result<(), Self::Error> { let mut conn = context.conn().await?; + insert_activity(&self.id, &self, false, false, context).await?; let form = PostUpdateForm::builder().locked(Some(false)).build(); let post = self.object.object.dereference(context).await?; @@ -114,6 +116,7 @@ impl SendActivity for LockPost { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let id = generate_activity_id( LockType::Lock, diff --git a/crates/apub/src/activities/community/mod.rs b/crates/apub/src/activities/community/mod.rs index fa48b99e4..e92e64d02 100644 --- a/crates/apub/src/activities/community/mod.rs +++ b/crates/apub/src/activities/community/mod.rs @@ -38,7 +38,8 @@ pub(crate) async fn send_activity_in_community( is_mod_action: bool, context: &Data, ) -> Result<(), LemmyError> { - let mut conn = context.conn().await?; // send to any users which are mentioned or affected directly + let mut conn = context.conn().await?; + // send to any users which are mentioned or affected directly let mut inboxes = extra_inboxes; // send to user followers diff --git a/crates/apub/src/activities/community/report.rs b/crates/apub/src/activities/community/report.rs index 3babbfa26..91bc33c85 100644 --- a/crates/apub/src/activities/community/report.rs +++ b/crates/apub/src/activities/community/report.rs @@ -123,6 +123,7 @@ impl ActivityHandler for Report { #[tracing::instrument(skip_all)] async fn receive(self, context: &Data) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + insert_activity(&self.id, &self, false, true, context).await?; let actor = self.actor.dereference(context).await?; match self.object.dereference(context).await? { diff --git a/crates/apub/src/activities/community/update.rs b/crates/apub/src/activities/community/update.rs index 7f32dd55c..5b76e9deb 100644 --- a/crates/apub/src/activities/community/update.rs +++ b/crates/apub/src/activities/community/update.rs @@ -36,6 +36,7 @@ impl SendActivity for EditCommunity { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let community = Community::read(&mut conn, request.community_id).await?; UpdateCommunity::send(community.into(), &local_user_view.person.into(), context).await @@ -94,6 +95,7 @@ impl ActivityHandler for UpdateCommunity { #[tracing::instrument(skip_all)] async fn receive(self, context: &Data) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + insert_activity(&self.id, &self, false, false, context).await?; let community = self.community(context).await?; @@ -114,6 +116,7 @@ impl SendActivity for HideCommunity { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let community = Community::read(&mut conn, request.community_id).await?; UpdateCommunity::send(community.into(), &local_user_view.person.into(), context).await diff --git a/crates/apub/src/activities/create_or_update/comment.rs b/crates/apub/src/activities/create_or_update/comment.rs index da32eee28..923fd5edf 100644 --- a/crates/apub/src/activities/create_or_update/comment.rs +++ b/crates/apub/src/activities/create_or_update/comment.rs @@ -89,7 +89,8 @@ impl CreateOrUpdateNote { kind: CreateOrUpdateType, context: &Data, ) -> Result<(), LemmyError> { - let mut conn = context.conn().await?; // TODO: might be helpful to add a comment method to retrieve community directly + let mut conn = context.conn().await?; + // TODO: might be helpful to add a comment method to retrieve community directly let post_id = comment.post_id; let post = Post::read(&mut conn, post_id).await?; let community_id = post.community_id; @@ -168,6 +169,7 @@ impl ActivityHandler for CreateOrUpdateNote { #[tracing::instrument(skip_all)] async fn receive(self, context: &Data) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + insert_activity(&self.id, &self, false, false, context).await?; // Need to do this check here instead of Note::from_json because we need the person who // send the activity, not the comment author. diff --git a/crates/apub/src/activities/create_or_update/post.rs b/crates/apub/src/activities/create_or_update/post.rs index a43788288..5fdf723be 100644 --- a/crates/apub/src/activities/create_or_update/post.rs +++ b/crates/apub/src/activities/create_or_update/post.rs @@ -108,6 +108,7 @@ impl CreateOrUpdatePage { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let post = ApubPost(post.clone()); let community_id = post.community_id; let person: ApubPerson = Person::read(&mut conn, person_id).await?.into(); @@ -180,6 +181,7 @@ impl ActivityHandler for CreateOrUpdatePage { #[tracing::instrument(skip_all)] async fn receive(self, context: &Data) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + insert_activity(&self.id, &self, false, false, context).await?; let post = ApubPost::from_json(self.object, context).await?; diff --git a/crates/apub/src/activities/create_or_update/private_message.rs b/crates/apub/src/activities/create_or_update/private_message.rs index c34c68995..0f29e9cc9 100644 --- a/crates/apub/src/activities/create_or_update/private_message.rs +++ b/crates/apub/src/activities/create_or_update/private_message.rs @@ -71,6 +71,7 @@ impl CreateOrUpdateChatMessage { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let recipient_id = private_message.recipient_id; let sender: ApubPerson = Person::read(&mut conn, sender_id).await?.into(); let recipient: ApubPerson = Person::read(&mut conn, recipient_id).await?.into(); diff --git a/crates/apub/src/activities/deletion/delete.rs b/crates/apub/src/activities/deletion/delete.rs index 692d1d6c5..6e111df10 100644 --- a/crates/apub/src/activities/deletion/delete.rs +++ b/crates/apub/src/activities/deletion/delete.rs @@ -106,6 +106,7 @@ pub(in crate::activities) async fn receive_remove_action( context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + match DeletableObjects::read_from_db(object, context).await? { DeletableObjects::Community(community) => { if community.local { diff --git a/crates/apub/src/activities/deletion/delete_user.rs b/crates/apub/src/activities/deletion/delete_user.rs index da31bc4bc..bd1d64588 100644 --- a/crates/apub/src/activities/deletion/delete_user.rs +++ b/crates/apub/src/activities/deletion/delete_user.rs @@ -29,6 +29,7 @@ impl SendActivity for DeleteAccount { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let actor: ApubPerson = local_user_view.person.into(); delete_user_account(actor.id, &mut conn, context.settings(), context.client()).await?; @@ -76,6 +77,7 @@ impl ActivityHandler for DeleteUser { async fn receive(self, context: &Data) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + insert_activity(&self.id, &self, false, false, context).await?; let actor = self.actor.dereference(context).await?; delete_user_account(actor.id, &mut conn, context.settings(), context.client()).await?; diff --git a/crates/apub/src/activities/deletion/mod.rs b/crates/apub/src/activities/deletion/mod.rs index 7fdcefd35..7de13e247 100644 --- a/crates/apub/src/activities/deletion/mod.rs +++ b/crates/apub/src/activities/deletion/mod.rs @@ -64,6 +64,7 @@ impl SendActivity for DeletePost { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let community = Community::read(&mut conn, response.post_view.community.id).await?; let deletable = DeletableObjects::Post(response.post_view.post.clone().into()); @@ -89,6 +90,7 @@ impl SendActivity for RemovePost { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let community = Community::read(&mut conn, response.post_view.community.id).await?; let deletable = DeletableObjects::Post(response.post_view.post.clone().into()); @@ -114,6 +116,7 @@ impl SendActivity for DeleteComment { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let community_id = response.comment_view.community.id; let community = Community::read(&mut conn, community_id).await?; let person = Person::read(&mut conn, response.comment_view.creator.id).await?; @@ -133,6 +136,7 @@ impl SendActivity for RemoveComment { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let comment = Comment::read(&mut conn, request.comment_id).await?; let community = Community::read(&mut conn, response.comment_view.community.id).await?; @@ -179,6 +183,7 @@ impl SendActivity for DeleteCommunity { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let community = Community::read(&mut conn, request.community_id).await?; let deletable = DeletableObjects::Community(community.clone().into()); @@ -204,6 +209,7 @@ impl SendActivity for RemoveCommunity { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let community = Community::read(&mut conn, request.community_id).await?; let deletable = DeletableObjects::Community(community.clone().into()); @@ -258,6 +264,7 @@ async fn send_apub_delete_private_message( context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let recipient_id = pm.recipient_id; let recipient: ApubPerson = Person::read(&mut conn, recipient_id).await?.into(); @@ -386,6 +393,7 @@ async fn receive_delete_action( context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + match DeletableObjects::read_from_db(object, context).await? { DeletableObjects::Community(community) => { if community.local { diff --git a/crates/apub/src/activities/deletion/undo_delete.rs b/crates/apub/src/activities/deletion/undo_delete.rs index 654d578a1..399b8a66e 100644 --- a/crates/apub/src/activities/deletion/undo_delete.rs +++ b/crates/apub/src/activities/deletion/undo_delete.rs @@ -98,6 +98,7 @@ impl UndoDelete { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + match DeletableObjects::read_from_db(object, context).await? { DeletableObjects::Community(community) => { if community.local { diff --git a/crates/apub/src/activities/following/accept.rs b/crates/apub/src/activities/following/accept.rs index dd1c93e3d..1a9ea8cec 100644 --- a/crates/apub/src/activities/following/accept.rs +++ b/crates/apub/src/activities/following/accept.rs @@ -61,6 +61,7 @@ impl ActivityHandler for AcceptFollow { #[tracing::instrument(skip_all)] async fn receive(self, context: &Data) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + insert_activity(&self.id, &self, false, true, context).await?; let community = self.actor.dereference(context).await?; let person = self.object.actor.dereference(context).await?; diff --git a/crates/apub/src/activities/following/follow.rs b/crates/apub/src/activities/following/follow.rs index 8b860e2ca..5ce2b7502 100644 --- a/crates/apub/src/activities/following/follow.rs +++ b/crates/apub/src/activities/following/follow.rs @@ -61,6 +61,7 @@ impl Follow { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let community_follower_form = CommunityFollowerForm { community_id: community.id, person_id: actor.id, @@ -105,6 +106,7 @@ impl ActivityHandler for Follow { #[tracing::instrument(skip_all)] async fn receive(self, context: &Data) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + insert_activity(&self.id, &self, false, true, context).await?; let actor = self.actor.dereference(context).await?; let object = self.object.dereference(context).await?; @@ -141,6 +143,7 @@ impl SendActivity for BlockCommunity { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let community = Community::read(&mut conn, request.community_id).await?; UndoFollow::send(&local_user_view.person.into(), &community.into(), context).await diff --git a/crates/apub/src/activities/following/mod.rs b/crates/apub/src/activities/following/mod.rs index b0c88d71a..862231bae 100644 --- a/crates/apub/src/activities/following/mod.rs +++ b/crates/apub/src/activities/following/mod.rs @@ -26,6 +26,7 @@ impl SendActivity for FollowCommunity { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let person = local_user_view.person.clone().into(); let community: ApubCommunity = Community::read(&mut conn, request.community_id) diff --git a/crates/apub/src/activities/following/undo_follow.rs b/crates/apub/src/activities/following/undo_follow.rs index 737ae7cfe..8d6acabc2 100644 --- a/crates/apub/src/activities/following/undo_follow.rs +++ b/crates/apub/src/activities/following/undo_follow.rs @@ -72,6 +72,7 @@ impl ActivityHandler for UndoFollow { #[tracing::instrument(skip_all)] async fn receive(self, context: &Data) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + insert_activity(&self.id, &self, false, true, context).await?; let person = self.actor.dereference(context).await?; let object = self.object.object.dereference(context).await?; diff --git a/crates/apub/src/activities/mod.rs b/crates/apub/src/activities/mod.rs index c7cf27ce7..0c70da8d6 100644 --- a/crates/apub/src/activities/mod.rs +++ b/crates/apub/src/activities/mod.rs @@ -54,6 +54,7 @@ pub(crate) async fn verify_person_in_community( context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let person = person_id.dereference(context).await?; if person.banned { return Err(LemmyError::from_message("Person is banned from site")); @@ -83,6 +84,7 @@ pub(crate) async fn verify_mod_action( context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let mod_ = mod_id.dereference(context).await?; let is_mod_or_admin = CommunityView::is_mod_or_admin(&mut conn, mod_.id, community_id).await?; diff --git a/crates/apub/src/activities/voting/mod.rs b/crates/apub/src/activities/voting/mod.rs index 0a09c034e..6e679e572 100644 --- a/crates/apub/src/activities/voting/mod.rs +++ b/crates/apub/src/activities/voting/mod.rs @@ -84,6 +84,7 @@ async fn send_activity( context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let community = Community::read(&mut conn, community_id).await?.into(); let local_user_view = local_user_view_from_jwt(jwt, context).await?; let actor = Person::read(&mut conn, local_user_view.person.id) @@ -112,6 +113,7 @@ async fn vote_comment( context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let comment_id = comment.id; let like_form = CommentLikeForm { comment_id, @@ -133,6 +135,7 @@ async fn vote_post( context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let post_id = post.id; let like_form = PostLikeForm { post_id: post.id, @@ -152,6 +155,7 @@ async fn undo_vote_comment( context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let comment_id = comment.id; let person_id = actor.id; CommentLike::remove(&mut conn, person_id, comment_id).await?; @@ -165,6 +169,7 @@ async fn undo_vote_post( context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let post_id = post.id; let person_id = actor.id; PostLike::remove(&mut conn, person_id, post_id).await?; diff --git a/crates/apub/src/api/list_comments.rs b/crates/apub/src/api/list_comments.rs index e68cedb0c..6738b9c22 100644 --- a/crates/apub/src/api/list_comments.rs +++ b/crates/apub/src/api/list_comments.rs @@ -23,6 +23,7 @@ impl PerformApub for GetComments { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &GetComments = self; let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await; let local_site = LocalSite::read(&mut conn).await?; @@ -56,6 +57,7 @@ impl PerformApub for GetComments { let post_id = data.post_id; let local_user = local_user_view.map(|l| l.local_user); let mut conn = context.conn().await?; + let comments = CommentQuery::builder() .conn(&mut conn) .listing_type(Some(listing_type)) diff --git a/crates/apub/src/api/list_posts.rs b/crates/apub/src/api/list_posts.rs index cdd8a4b96..38776c00b 100644 --- a/crates/apub/src/api/list_posts.rs +++ b/crates/apub/src/api/list_posts.rs @@ -20,6 +20,7 @@ impl PerformApub for GetPosts { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &GetPosts = self; let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await; let local_site = LocalSite::read(&mut conn).await?; @@ -47,6 +48,7 @@ impl PerformApub for GetPosts { .is_ok(); let mut conn = context.conn().await?; + let posts = PostQuery::builder() .conn(&mut conn) .local_user(local_user_view.map(|l| l.local_user).as_ref()) diff --git a/crates/apub/src/api/read_community.rs b/crates/apub/src/api/read_community.rs index 860eb72d3..7b07a10a9 100644 --- a/crates/apub/src/api/read_community.rs +++ b/crates/apub/src/api/read_community.rs @@ -28,6 +28,7 @@ impl PerformApub for GetCommunity { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let data: &GetCommunity = self; let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await; let local_site = LocalSite::read(&mut conn).await?; diff --git a/crates/apub/src/api/read_person.rs b/crates/apub/src/api/read_person.rs index 617b43eee..60d1e38dd 100644 --- a/crates/apub/src/api/read_person.rs +++ b/crates/apub/src/api/read_person.rs @@ -23,6 +23,7 @@ impl PerformApub for GetPersonDetails { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let data: &GetPersonDetails = self; // Check to make sure a person name or an id is given @@ -65,6 +66,7 @@ impl PerformApub for GetPersonDetails { let local_user_clone = local_user.clone(); let mut conn = context.conn().await?; + let posts_query = PostQuery::builder() .conn(&mut conn) .sort(sort) @@ -88,6 +90,7 @@ impl PerformApub for GetPersonDetails { .await?; let mut conn = context.conn().await?; + let comments_query = CommentQuery::builder() .conn(&mut conn) .local_user(local_user_clone.as_ref()) diff --git a/crates/apub/src/api/resolve_object.rs b/crates/apub/src/api/resolve_object.rs index 48551ee37..801fa049f 100644 --- a/crates/apub/src/api/resolve_object.rs +++ b/crates/apub/src/api/resolve_object.rs @@ -24,6 +24,7 @@ impl PerformApub for ResolveObject { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let local_user_view = local_user_view_from_jwt(&self.auth, context).await?; let local_site = LocalSite::read(&mut conn).await?; let person_id = local_user_view.person.id; diff --git a/crates/apub/src/api/search.rs b/crates/apub/src/api/search.rs index 01eb219c7..57e09de42 100644 --- a/crates/apub/src/api/search.rs +++ b/crates/apub/src/api/search.rs @@ -25,6 +25,7 @@ impl PerformApub for Search { #[tracing::instrument(skip(context))] async fn perform(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let data: &Search = self; let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await; @@ -58,6 +59,7 @@ impl PerformApub for Search { let creator_id = data.creator_id; let local_user = local_user_view.map(|l| l.local_user); let mut conn = context.conn().await?; + match search_type { SearchType::Posts => { posts = PostQuery::builder() diff --git a/crates/apub/src/fetcher/mod.rs b/crates/apub/src/fetcher/mod.rs index 2a1e1dd49..d75272123 100644 --- a/crates/apub/src/fetcher/mod.rs +++ b/crates/apub/src/fetcher/mod.rs @@ -35,7 +35,8 @@ where for<'de2> ::Kind: serde::Deserialize<'de2>, DbActor: ApubActor + Send + 'static, { - let mut conn = context.conn().await?; // remote actor + let mut conn = context.conn().await?; + // remote actor if identifier.contains('@') { let (name, domain) = identifier .splitn(2, '@') diff --git a/crates/apub/src/fetcher/post_or_comment.rs b/crates/apub/src/fetcher/post_or_comment.rs index 29651d488..68f1aaa49 100644 --- a/crates/apub/src/fetcher/post_or_comment.rs +++ b/crates/apub/src/fetcher/post_or_comment.rs @@ -90,6 +90,7 @@ impl Object for PostOrComment { impl InCommunity for PostOrComment { async fn community(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let cid = match self { PostOrComment::Post(p) => p.community_id, PostOrComment::Comment(c) => Post::read(&mut conn, c.post_id).await?.community_id, diff --git a/crates/apub/src/http/comment.rs b/crates/apub/src/http/comment.rs index ce497b95a..d77f61822 100644 --- a/crates/apub/src/http/comment.rs +++ b/crates/apub/src/http/comment.rs @@ -21,6 +21,7 @@ pub(crate) async fn get_apub_comment( context: Data, ) -> Result { let mut conn = context.conn().await?; + let id = CommentId(info.comment_id.parse::()?); let comment: ApubComment = Comment::read(&mut conn, id).await?.into(); if !comment.local { diff --git a/crates/apub/src/http/community.rs b/crates/apub/src/http/community.rs index 7d140332b..3051b8f1d 100644 --- a/crates/apub/src/http/community.rs +++ b/crates/apub/src/http/community.rs @@ -33,6 +33,7 @@ pub(crate) async fn get_apub_community_http( context: Data, ) -> Result { let mut conn = context.conn().await?; + let community: ApubCommunity = Community::read_from_name(&mut conn, &info.community_name, true) .await? .into(); @@ -65,6 +66,7 @@ pub(crate) async fn get_apub_community_followers( context: Data, ) -> Result { let mut conn = context.conn().await?; + let community = Community::read_from_name(&mut conn, &info.community_name, false).await?; let followers = GroupFollowers::new(community, &context).await?; create_apub_response(&followers) @@ -77,6 +79,7 @@ pub(crate) async fn get_apub_community_outbox( context: Data, ) -> Result { let mut conn = context.conn().await?; + let community: ApubCommunity = Community::read_from_name(&mut conn, &info.community_name, false) .await? .into(); @@ -93,6 +96,7 @@ pub(crate) async fn get_apub_community_moderators( context: Data, ) -> Result { let mut conn = context.conn().await?; + let community: ApubCommunity = Community::read_from_name(&mut conn, &info.community_name, false) .await? .into(); @@ -109,6 +113,7 @@ pub(crate) async fn get_apub_community_featured( context: Data, ) -> Result { let mut conn = context.conn().await?; + let community: ApubCommunity = Community::read_from_name(&mut conn, &info.community_name, false) .await? .into(); diff --git a/crates/apub/src/http/mod.rs b/crates/apub/src/http/mod.rs index fea305ec3..a4c2d0dcd 100644 --- a/crates/apub/src/http/mod.rs +++ b/crates/apub/src/http/mod.rs @@ -83,6 +83,7 @@ pub(crate) async fn get_activity( context: web::Data, ) -> Result { let mut conn = context.conn().await?; + let settings = context.settings(); let activity_id = Url::parse(&format!( "{}/activities/{}/{}", diff --git a/crates/apub/src/http/person.rs b/crates/apub/src/http/person.rs index cd83bea2d..7fa6c51cc 100644 --- a/crates/apub/src/http/person.rs +++ b/crates/apub/src/http/person.rs @@ -29,6 +29,7 @@ pub(crate) async fn get_apub_person_http( context: Data, ) -> Result { let mut conn = context.conn().await?; + let user_name = info.into_inner().user_name; // TODO: this needs to be able to read deleted persons, so that it can send tombstones let person: ApubPerson = Person::read_from_name(&mut conn, &user_name, true) @@ -62,6 +63,7 @@ pub(crate) async fn get_apub_person_outbox( context: Data, ) -> Result { let mut conn = context.conn().await?; + let person = Person::read_from_name(&mut conn, &info.user_name, false).await?; let outbox_id = generate_outbox_url(&person.actor_id)?.into(); let outbox = EmptyOutbox::new(outbox_id)?; diff --git a/crates/apub/src/http/post.rs b/crates/apub/src/http/post.rs index 3ab1692c1..02e7c5a01 100644 --- a/crates/apub/src/http/post.rs +++ b/crates/apub/src/http/post.rs @@ -21,6 +21,7 @@ pub(crate) async fn get_apub_post( context: Data, ) -> Result { let mut conn = context.conn().await?; + let id = PostId(info.post_id.parse::()?); let post: ApubPost = Post::read(&mut conn, id).await?.into(); if !post.local { diff --git a/crates/apub/src/http/site.rs b/crates/apub/src/http/site.rs index eadd9765c..05cb46ebe 100644 --- a/crates/apub/src/http/site.rs +++ b/crates/apub/src/http/site.rs @@ -20,6 +20,7 @@ pub(crate) async fn get_apub_site_http( context: Data, ) -> Result { let mut conn = context.conn().await?; + let site: ApubSite = SiteView::read_local(&mut conn).await?.site.into(); let apub = site.into_json(&context).await?; diff --git a/crates/apub/src/mentions.rs b/crates/apub/src/mentions.rs index 24c10e8b6..7287e6b89 100644 --- a/crates/apub/src/mentions.rs +++ b/crates/apub/src/mentions.rs @@ -46,6 +46,7 @@ pub async fn collect_non_local_mentions( context: &Data, ) -> Result { let mut conn = context.conn().await?; + let parent_creator = get_comment_parent_creator(&mut conn, comment).await?; let mut addressed_ccs: Vec = vec![community_id.into(), parent_creator.id()]; diff --git a/crates/apub/src/objects/comment.rs b/crates/apub/src/objects/comment.rs index 91577a867..fdc8cd5f8 100644 --- a/crates/apub/src/objects/comment.rs +++ b/crates/apub/src/objects/comment.rs @@ -67,6 +67,7 @@ impl Object for ApubComment { context: &Data, ) -> Result, LemmyError> { let mut conn = context.conn().await?; + Ok( Comment::read_from_apub_id(&mut conn, object_id) .await? @@ -77,6 +78,7 @@ impl Object for ApubComment { #[tracing::instrument(skip_all)] async fn delete(self, context: &Data) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + if !self.deleted { let form = CommentUpdateForm::builder().deleted(Some(true)).build(); Comment::update(&mut conn, self.id, &form).await?; @@ -87,6 +89,7 @@ impl Object for ApubComment { #[tracing::instrument(skip_all)] async fn into_json(self, context: &Data) -> Result { let mut conn = context.conn().await?; + let creator_id = self.creator_id; let creator = Person::read(&mut conn, creator_id).await?; @@ -132,6 +135,7 @@ impl Object for ApubComment { context: &Data, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + verify_domains_match(note.id.inner(), expected_domain)?; verify_domains_match(note.attributed_to.inner(), note.id.inner())?; verify_is_public(¬e.to, ¬e.cc)?; @@ -159,6 +163,7 @@ impl Object for ApubComment { #[tracing::instrument(skip_all)] async fn from_json(note: Note, context: &Data) -> Result { let mut conn = context.conn().await?; + let creator = note.attributed_to.dereference(context).await?; let (post, parent_comment) = note.get_parents(context).await?; diff --git a/crates/apub/src/objects/community.rs b/crates/apub/src/objects/community.rs index 5b646ceeb..e5a1f69a7 100644 --- a/crates/apub/src/objects/community.rs +++ b/crates/apub/src/objects/community.rs @@ -67,6 +67,7 @@ impl Object for ApubCommunity { context: &Data, ) -> Result, LemmyError> { let mut conn = context.conn().await?; + Ok( Community::read_from_apub_id(&mut conn, &object_id.into()) .await? @@ -77,6 +78,7 @@ impl Object for ApubCommunity { #[tracing::instrument(skip_all)] async fn delete(self, context: &Data) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let form = CommunityUpdateForm::builder().deleted(Some(true)).build(); Community::update(&mut conn, self.id, &form).await?; Ok(()) @@ -131,6 +133,7 @@ impl Object for ApubCommunity { context: &Data, ) -> Result { let mut conn = context.conn().await?; + let instance_id = fetch_instance_actor_for_object(&group.id, context).await?; let form = Group::into_insert_form(group.clone(), instance_id); @@ -189,6 +192,7 @@ impl ApubCommunity { context: &LemmyContext, ) -> Result, LemmyError> { let mut conn = context.conn().await?; + let id = self.id; let local_site_data = fetch_local_site_data(&mut conn).await?; diff --git a/crates/apub/src/objects/instance.rs b/crates/apub/src/objects/instance.rs index 01befebc3..bd8212886 100644 --- a/crates/apub/src/objects/instance.rs +++ b/crates/apub/src/objects/instance.rs @@ -177,6 +177,7 @@ pub(in crate::objects) async fn fetch_instance_actor_for_object + C context: &Data, ) -> Result { let mut conn = context.conn().await?; + let object_id: Url = object_id.clone().into(); let instance_id = Site::instance_actor_id_from_url(object_id); let site = ObjectId::::from(instance_id.clone()) diff --git a/crates/apub/src/objects/post.rs b/crates/apub/src/objects/post.rs index 4f3e60237..47498494d 100644 --- a/crates/apub/src/objects/post.rs +++ b/crates/apub/src/objects/post.rs @@ -83,6 +83,7 @@ impl Object for ApubPost { context: &Data, ) -> Result, LemmyError> { let mut conn = context.conn().await?; + Ok( Post::read_from_apub_id(&mut conn, object_id) .await? @@ -93,6 +94,7 @@ impl Object for ApubPost { #[tracing::instrument(skip_all)] async fn delete(self, context: &Data) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + if !self.deleted { let form = PostUpdateForm::builder().deleted(Some(true)).build(); Post::update(&mut conn, self.id, &form).await?; @@ -104,6 +106,7 @@ impl Object for ApubPost { #[tracing::instrument(skip_all)] async fn into_json(self, context: &Data) -> Result { let mut conn = context.conn().await?; + let creator_id = self.creator_id; let creator = Person::read(&mut conn, creator_id).await?; let community_id = self.community_id; @@ -139,8 +142,9 @@ impl Object for ApubPost { expected_domain: &Url, context: &Data, ) -> Result<(), LemmyError> { - let mut conn = context.conn().await?; // We can't verify the domain in case of mod action, because the mod may be on a different - // instance from the post author. + let mut conn = context.conn().await?; + // We can't verify the domain in case of mod action, because the mod may be on a different + // instance from the post author. if !page.is_mod_action(context).await? { verify_domains_match(page.id.inner(), expected_domain)?; verify_is_remote_object(page.id.inner(), context.settings())?; @@ -168,6 +172,7 @@ impl Object for ApubPost { #[tracing::instrument(skip_all)] async fn from_json(page: Page, context: &Data) -> Result { let mut conn = context.conn().await?; + let creator = page.creator()?.dereference(context).await?; let community = page.community(context).await?; if community.posting_restricted_to_mods { diff --git a/crates/apub/src/protocol/activities/community/collection_add.rs b/crates/apub/src/protocol/activities/community/collection_add.rs index fe38f07bb..5afc6dc32 100644 --- a/crates/apub/src/protocol/activities/community/collection_add.rs +++ b/crates/apub/src/protocol/activities/community/collection_add.rs @@ -35,6 +35,7 @@ pub struct CollectionAdd { impl InCommunity for CollectionAdd { async fn community(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let (community, _) = Community::get_by_collection_url(&mut conn, &self.clone().target.into()).await?; if let Some(audience) = &self.audience { diff --git a/crates/apub/src/protocol/activities/community/collection_remove.rs b/crates/apub/src/protocol/activities/community/collection_remove.rs index 5d586ccae..fc696eba3 100644 --- a/crates/apub/src/protocol/activities/community/collection_remove.rs +++ b/crates/apub/src/protocol/activities/community/collection_remove.rs @@ -35,6 +35,7 @@ pub struct CollectionRemove { impl InCommunity for CollectionRemove { async fn community(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let (community, _) = Community::get_by_collection_url(&mut conn, &self.clone().target.into()).await?; if let Some(audience) = &self.audience { diff --git a/crates/apub/src/protocol/activities/community/lock_page.rs b/crates/apub/src/protocol/activities/community/lock_page.rs index 037843033..10c39ae9e 100644 --- a/crates/apub/src/protocol/activities/community/lock_page.rs +++ b/crates/apub/src/protocol/activities/community/lock_page.rs @@ -55,6 +55,7 @@ pub struct UndoLockPage { impl InCommunity for LockPage { async fn community(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let post = self.object.dereference(context).await?; let community = Community::read(&mut conn, post.community_id).await?; if let Some(audience) = &self.audience { diff --git a/crates/apub/src/protocol/activities/create_or_update/note.rs b/crates/apub/src/protocol/activities/create_or_update/note.rs index 6f3197e8b..f79fa7f83 100644 --- a/crates/apub/src/protocol/activities/create_or_update/note.rs +++ b/crates/apub/src/protocol/activities/create_or_update/note.rs @@ -36,6 +36,7 @@ pub struct CreateOrUpdateNote { impl InCommunity for CreateOrUpdateNote { async fn community(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let post = self.object.get_parents(context).await?.0; let community = Community::read(&mut conn, post.community_id).await?; if let Some(audience) = &self.audience { diff --git a/crates/apub/src/protocol/activities/deletion/delete.rs b/crates/apub/src/protocol/activities/deletion/delete.rs index fd3c8144c..2f7b0509f 100644 --- a/crates/apub/src/protocol/activities/deletion/delete.rs +++ b/crates/apub/src/protocol/activities/deletion/delete.rs @@ -46,6 +46,7 @@ pub struct Delete { impl InCommunity for Delete { async fn community(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let community_id = match DeletableObjects::read_from_db(self.object.id(), context).await? { DeletableObjects::Community(c) => c.id, DeletableObjects::Comment(c) => { diff --git a/crates/apub/src/protocol/collections/group_followers.rs b/crates/apub/src/protocol/collections/group_followers.rs index f477cb4fc..577f86a42 100644 --- a/crates/apub/src/protocol/collections/group_followers.rs +++ b/crates/apub/src/protocol/collections/group_followers.rs @@ -21,6 +21,7 @@ impl GroupFollowers { context: &LemmyContext, ) -> Result { let mut conn = context.conn().await?; + let community_id = community.id; let community_followers = CommunityFollowerView::for_community(&mut conn, community_id).await?; diff --git a/crates/apub/src/protocol/objects/group.rs b/crates/apub/src/protocol/objects/group.rs index a9788c1ee..14501e2e2 100644 --- a/crates/apub/src/protocol/objects/group.rs +++ b/crates/apub/src/protocol/objects/group.rs @@ -81,6 +81,7 @@ impl Group { context: &LemmyContext, ) -> Result<(), LemmyError> { let mut conn = context.conn().await?; + let local_site_data = fetch_local_site_data(&mut conn).await?; check_apub_id_valid_with_strictness( diff --git a/crates/apub/src/protocol/objects/note.rs b/crates/apub/src/protocol/objects/note.rs index dedeede14..13da744d7 100644 --- a/crates/apub/src/protocol/objects/note.rs +++ b/crates/apub/src/protocol/objects/note.rs @@ -58,7 +58,8 @@ impl Note { &self, context: &Data, ) -> Result<(ApubPost, Option), LemmyError> { - let mut conn = context.conn().await?; // Fetch parent comment chain in a box, otherwise it can cause a stack overflow. + let mut conn = context.conn().await?; + // Fetch parent comment chain in a box, otherwise it can cause a stack overflow. let parent = Box::pin(self.in_reply_to.dereference(context).await?); match parent.deref() { PostOrComment::Post(p) => Ok((p.clone(), None)), @@ -75,6 +76,7 @@ impl Note { impl InCommunity for Note { async fn community(&self, context: &Data) -> Result { let mut conn = context.conn().await?; + let (post, _) = self.get_parents(context).await?; let community = Community::read(&mut conn, post.community_id).await?; if let Some(audience) = &self.audience { diff --git a/crates/db_schema/src/impls/actor_language.rs b/crates/db_schema/src/impls/actor_language.rs index c730d725d..692bafff6 100644 --- a/crates/db_schema/src/impls/actor_language.rs +++ b/crates/db_schema/src/impls/actor_language.rs @@ -561,6 +561,7 @@ mod tests { #[serial] async fn test_community_languages() { let conn = &mut build_db_conn_for_tests().await; + let (site, instance) = create_test_site(conn).await; let test_langs = test_langs1(conn).await; SiteLanguage::update(conn, test_langs.clone(), &site) @@ -622,6 +623,7 @@ mod tests { #[serial] async fn test_default_post_language() { let conn = &mut build_db_conn_for_tests().await; + let (site, instance) = create_test_site(conn).await; let test_langs = test_langs1(conn).await; let test_langs2 = test_langs2(conn).await; diff --git a/crates/db_schema/src/impls/federation_allowlist.rs b/crates/db_schema/src/impls/federation_allowlist.rs index 15b4c67d0..63d54077a 100644 --- a/crates/db_schema/src/impls/federation_allowlist.rs +++ b/crates/db_schema/src/impls/federation_allowlist.rs @@ -58,6 +58,7 @@ mod tests { #[serial] async fn test_allowlist_insert_and_clear() { let conn = &mut build_db_conn_for_tests().await; + let domains = vec![ "tld1.xyz".to_string(), "tld2.xyz".to_string(), diff --git a/crates/db_schema/src/impls/person.rs b/crates/db_schema/src/impls/person.rs index ef68a66b1..72541a620 100644 --- a/crates/db_schema/src/impls/person.rs +++ b/crates/db_schema/src/impls/person.rs @@ -257,6 +257,7 @@ mod tests { #[serial] async fn follow() { let conn = &mut build_db_conn_for_tests().await; + let inserted_instance = Instance::read_or_create(conn, "my_domain.tld".to_string()) .await .unwrap(); diff --git a/crates/db_schema/src/utils.rs b/crates/db_schema/src/utils.rs index f344df6a8..3843b3447 100644 --- a/crates/db_schema/src/utils.rs +++ b/crates/db_schema/src/utils.rs @@ -48,6 +48,7 @@ const POOL_TIMEOUT: Option = Some(Duration::from_secs(5)); pub type DbPool = Pool; pub type DbConn = AsyncPgConnection; + pub type DbPooledConn = PooledConnection; pub async fn get_conn(pool: &DbPool) -> Result, DieselError> { diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index dcc114f07..ece7c95ed 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -588,6 +588,7 @@ mod tests { #[serial] async fn test_crud() { let conn = &mut build_db_conn_for_tests().await; + let data = init_data(conn).await; let expected_comment_view_no_person = expected_comment_view(&data, conn).await; @@ -645,6 +646,7 @@ mod tests { #[serial] async fn test_comment_tree() { let conn = &mut build_db_conn_for_tests().await; + let data = init_data(conn).await; let top_path = data.inserted_comment_0.path.clone(); @@ -721,6 +723,7 @@ mod tests { #[serial] async fn test_languages() { let conn = &mut build_db_conn_for_tests().await; + let data = init_data(conn).await; // by default, user has all languages enabled and should see all comments diff --git a/crates/db_views/src/post_report_view.rs b/crates/db_views/src/post_report_view.rs index 2b9d218d0..9102e526d 100644 --- a/crates/db_views/src/post_report_view.rs +++ b/crates/db_views/src/post_report_view.rs @@ -175,6 +175,7 @@ pub struct PostReportQuery<'a> { impl<'a> PostReportQuery<'a> { pub async fn list(self) -> Result, Error> { let conn = self.conn; + let (person_alias_1, person_alias_2) = diesel::alias!(person as person1, person as person2); let mut query = post_report::table diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post_view.rs index c4e21c60c..8536ac14b 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post_view.rs @@ -606,6 +606,7 @@ mod tests { #[serial] async fn post_listing_with_person() { let conn = &mut build_db_conn_for_tests().await; + let data = init_data(conn).await; let local_user_form = LocalUserUpdateForm::builder() @@ -674,6 +675,7 @@ mod tests { #[serial] async fn post_listing_no_person() { let conn = &mut build_db_conn_for_tests().await; + let data = init_data(conn).await; let read_post_listing_multiple_no_person = PostQuery::builder() @@ -711,6 +713,7 @@ mod tests { #[serial] async fn post_listing_block_community() { let conn = &mut build_db_conn_for_tests().await; + let data = init_data(conn).await; let community_block = CommunityBlockForm { @@ -741,6 +744,7 @@ mod tests { #[serial] async fn post_listing_like() { let conn = &mut build_db_conn_for_tests().await; + let data = init_data(conn).await; let post_like_form = PostLikeForm { @@ -807,6 +811,7 @@ mod tests { #[serial] async fn post_listing_person_language() { let conn = &mut build_db_conn_for_tests().await; + let data = init_data(conn).await; let spanish_id = Language::read_id_from_code(conn, Some("es")) @@ -888,6 +893,7 @@ mod tests { #[serial] async fn post_listings_deleted() { let conn = &mut build_db_conn_for_tests().await; + let data = init_data(conn).await; // Delete the post diff --git a/crates/db_views/src/private_message_report_view.rs b/crates/db_views/src/private_message_report_view.rs index 62a007eaf..c73bcaafc 100644 --- a/crates/db_views/src/private_message_report_view.rs +++ b/crates/db_views/src/private_message_report_view.rs @@ -89,6 +89,7 @@ pub struct PrivateMessageReportQuery<'a> { impl<'a> PrivateMessageReportQuery<'a> { pub async fn list(self) -> Result, Error> { let conn = self.conn; + let (person_alias_1, person_alias_2) = diesel::alias!(person as person1, person as person2); let mut query = private_message_report::table diff --git a/crates/db_views/src/private_message_view.rs b/crates/db_views/src/private_message_view.rs index f110b0b6c..be6c39ec3 100644 --- a/crates/db_views/src/private_message_view.rs +++ b/crates/db_views/src/private_message_view.rs @@ -81,6 +81,7 @@ pub struct PrivateMessageQuery<'a> { impl<'a> PrivateMessageQuery<'a> { pub async fn list(self) -> Result, Error> { let conn = self.conn; + let person_alias_1 = diesel::alias!(person as person1); let mut query = private_message::table diff --git a/crates/db_views/src/registration_application_view.rs b/crates/db_views/src/registration_application_view.rs index f5aaa21c9..dc9a6f265 100644 --- a/crates/db_views/src/registration_application_view.rs +++ b/crates/db_views/src/registration_application_view.rs @@ -98,6 +98,7 @@ pub struct RegistrationApplicationQuery<'a> { impl<'a> RegistrationApplicationQuery<'a> { pub async fn list(self) -> Result, Error> { let conn = self.conn; + let person_alias_1 = diesel::alias!(person as person1); let mut query = registration_application::table diff --git a/src/scheduled_tasks.rs b/src/scheduled_tasks.rs index 4d3c936e8..a918c9fb4 100644 --- a/src/scheduled_tasks.rs +++ b/src/scheduled_tasks.rs @@ -38,6 +38,7 @@ pub fn setup( let url = db_url.clone(); scheduler.every(CTimeUnits::hour(1)).run(move || { let mut conn = PgConnection::establish(&url).expect("could not establish connection"); + active_counts(&mut conn); update_banned_when_expired(&mut conn); }); @@ -46,6 +47,7 @@ pub fn setup( let url = db_url.clone(); scheduler.every(CTimeUnits::minutes(15)).run(move || { let mut conn = PgConnection::establish(&url).expect("could not establish connection"); + update_hot_ranks(&mut conn, true); }); @@ -53,6 +55,7 @@ pub fn setup( let url = db_url.clone(); scheduler.every(CTimeUnits::minutes(10)).run(move || { let mut conn = PgConnection::establish(&url).expect("could not establish connection"); + delete_expired_captcha_answers(&mut conn); }); @@ -60,6 +63,7 @@ pub fn setup( let url = db_url.clone(); scheduler.every(CTimeUnits::weeks(1)).run(move || { let mut conn = PgConnection::establish(&url).expect("could not establish connection"); + clear_old_activities(&mut conn); }); @@ -73,12 +77,14 @@ pub fn setup( let url = db_url.clone(); scheduler.every(CTimeUnits::days(1)).run(move || { let mut conn = PgConnection::establish(&url).expect("could not establish connection"); + overwrite_deleted_posts_and_comments(&mut conn); }); // Update the Instance Software scheduler.every(CTimeUnits::days(1)).run(move || { let mut conn = PgConnection::establish(&db_url).expect("could not establish connection"); + update_instance_software(&mut conn, &user_agent); }); @@ -92,6 +98,7 @@ pub fn setup( /// Run these on server startup fn startup_jobs(db_url: &str) { let mut conn = PgConnection::establish(db_url).expect("could not establish connection"); + active_counts(&mut conn); update_hot_ranks(&mut conn, false); update_banned_when_expired(&mut conn);