Add blank lines under each line with conn =

This commit is contained in:
dull b 2023-06-30 06:56:12 +00:00
parent d2c6263ea1
commit 773a6d3beb
137 changed files with 206 additions and 6 deletions

View file

@ -19,6 +19,7 @@ impl Perform for SaveComment {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommentResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommentResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &SaveComment = self; let data: &SaveComment = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -26,6 +26,7 @@ impl Perform for CreateCommentReport {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<CommentReportResponse, LemmyError> { ) -> Result<CommentReportResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &CreateCommentReport = self; let data: &CreateCommentReport = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?; let local_site = LocalSite::read(&mut conn).await?;

View file

@ -20,6 +20,7 @@ impl Perform for ResolveCommentReport {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<CommentReportResponse, LemmyError> { ) -> Result<CommentReportResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &ResolveCommentReport = self; let data: &ResolveCommentReport = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -25,6 +25,7 @@ impl Perform for AddModToCommunity {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<AddModToCommunityResponse, LemmyError> { ) -> Result<AddModToCommunityResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &AddModToCommunity = self; let data: &AddModToCommunity = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -33,6 +33,7 @@ impl Perform for BanFromCommunity {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<BanFromCommunityResponse, LemmyError> { ) -> Result<BanFromCommunityResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &BanFromCommunity = self; let data: &BanFromCommunity = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -25,6 +25,7 @@ impl Perform for BlockCommunity {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<BlockCommunityResponse, LemmyError> { ) -> Result<BlockCommunityResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &BlockCommunity = self; let data: &BlockCommunity = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -22,6 +22,7 @@ impl Perform for FollowCommunity {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommunityResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommunityResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &FollowCommunity = self; let data: &FollowCommunity = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -22,6 +22,7 @@ impl Perform for HideCommunity {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommunityResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommunityResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &HideCommunity = self; let data: &HideCommunity = self;
// Verify its a admin (only admin can hide or unhide it) // Verify its a admin (only admin can hide or unhide it)

View file

@ -28,6 +28,7 @@ impl Perform for TransferCommunity {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<GetCommunityResponse, LemmyError> { ) -> Result<GetCommunityResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &TransferCommunity = self; let data: &TransferCommunity = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -70,6 +70,7 @@ mod tests {
#[serial] #[serial]
async fn test_should_not_validate_user_token_after_password_change() { async fn test_should_not_validate_user_token_after_password_change() {
let conn = &mut build_db_conn_for_tests().await; let conn = &mut build_db_conn_for_tests().await;
let secret = Secret::init(conn).await.unwrap(); let secret = Secret::init(conn).await.unwrap();
let settings = &SETTINGS.to_owned(); let settings = &SETTINGS.to_owned();

View file

@ -22,6 +22,7 @@ impl Perform for AddAdmin {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<AddAdminResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<AddAdminResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &AddAdmin = self; let data: &AddAdmin = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -25,6 +25,7 @@ impl Perform for BanPerson {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<BanPersonResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<BanPersonResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &BanPerson = self; let data: &BanPerson = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -19,6 +19,7 @@ impl Perform for BlockPerson {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<BlockPersonResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<BlockPersonResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &BlockPerson = self; let data: &BlockPerson = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -16,6 +16,7 @@ impl Perform for ChangePassword {
#[tracing::instrument(skip(self, context))] #[tracing::instrument(skip(self, context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<LoginResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<LoginResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &ChangePassword = self; let data: &ChangePassword = self;
let local_user_view = local_user_view_from_jwt(data.auth.as_ref(), context).await?; let local_user_view = local_user_view_from_jwt(data.auth.as_ref(), context).await?;

View file

@ -19,6 +19,7 @@ impl Perform for PasswordChangeAfterReset {
#[tracing::instrument(skip(self, context))] #[tracing::instrument(skip(self, context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<LoginResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<LoginResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &PasswordChangeAfterReset = self; let data: &PasswordChangeAfterReset = self;
// Fetch the user_id from the token // Fetch the user_id from the token

View file

@ -18,6 +18,7 @@ impl Perform for GetCaptcha {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let local_site = LocalSite::read(&mut conn).await?; let local_site = LocalSite::read(&mut conn).await?;
if !local_site.captcha_enabled { if !local_site.captcha_enabled {

View file

@ -14,6 +14,7 @@ impl Perform for GetBannedPersons {
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &GetBannedPersons = self; let data: &GetBannedPersons = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -16,6 +16,7 @@ impl Perform for Login {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<LoginResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<LoginResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &Login = self; let data: &Login = self;
let site_view = SiteView::read_local(&mut conn).await?; let site_view = SiteView::read_local(&mut conn).await?;

View file

@ -28,6 +28,7 @@ impl Perform for GetPersonMentions {
let show_bot_accounts = Some(local_user_view.local_user.show_bot_accounts); let show_bot_accounts = Some(local_user_view.local_user.show_bot_accounts);
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let mentions = PersonMentionQuery::builder() let mentions = PersonMentionQuery::builder()
.conn(&mut conn) .conn(&mut conn)
.recipient_id(person_id) .recipient_id(person_id)

View file

@ -25,6 +25,7 @@ impl Perform for GetReplies {
let show_bot_accounts = Some(local_user_view.local_user.show_bot_accounts); let show_bot_accounts = Some(local_user_view.local_user.show_bot_accounts);
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let replies = CommentReplyQuery::builder() let replies = CommentReplyQuery::builder()
.conn(&mut conn) .conn(&mut conn)
.recipient_id(person_id) .recipient_id(person_id)

View file

@ -19,6 +19,7 @@ impl Perform for MarkAllAsRead {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<GetRepliesResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<GetRepliesResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &MarkAllAsRead = self; let data: &MarkAllAsRead = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let person_id = local_user_view.person.id; let person_id = local_user_view.person.id;

View file

@ -22,6 +22,7 @@ impl Perform for MarkPersonMentionAsRead {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<PersonMentionResponse, LemmyError> { ) -> Result<PersonMentionResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &MarkPersonMentionAsRead = self; let data: &MarkPersonMentionAsRead = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -22,6 +22,7 @@ impl Perform for MarkCommentReplyAsRead {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<CommentReplyResponse, LemmyError> { ) -> Result<CommentReplyResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data = self; let data = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -16,6 +16,7 @@ impl Perform for GetUnreadCount {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data = self; let data = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -18,6 +18,7 @@ impl Perform for GetReportCount {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<GetReportCountResponse, LemmyError> { ) -> Result<GetReportCountResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &GetReportCount = self; let data: &GetReportCount = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -19,6 +19,7 @@ impl Perform for PasswordReset {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<PasswordResetResponse, LemmyError> { ) -> Result<PasswordResetResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &PasswordReset = self; let data: &PasswordReset = self;
// Fetch that email // Fetch that email

View file

@ -34,6 +34,7 @@ impl Perform for SaveUserSettings {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<LoginResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<LoginResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &SaveUserSettings = self; let data: &SaveUserSettings = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let site_view = SiteView::read_local(&mut conn).await?; let site_view = SiteView::read_local(&mut conn).await?;

View file

@ -19,6 +19,7 @@ impl Perform for VerifyEmail {
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let token = self.token.clone(); let token = self.token.clone();
let verification = EmailVerification::read_for_token(&mut conn, &token) let verification = EmailVerification::read_for_token(&mut conn, &token)
.await .await

View file

@ -29,6 +29,7 @@ impl Perform for FeaturePost {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &FeaturePost = self; let data: &FeaturePost = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -28,6 +28,7 @@ impl Perform for CreatePostLike {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &CreatePostLike = self; let data: &CreatePostLike = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?; let local_site = LocalSite::read(&mut conn).await?;

View file

@ -27,6 +27,7 @@ impl Perform for LockPost {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &LockPost = self; let data: &LockPost = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -15,6 +15,7 @@ impl Perform for MarkPostAsRead {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data = self; let data = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -19,6 +19,7 @@ impl Perform for SavePost {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &SavePost = self; let data: &SavePost = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -23,6 +23,7 @@ impl Perform for CreatePostReport {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostReportResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostReportResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &CreatePostReport = self; let data: &CreatePostReport = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?; let local_site = LocalSite::read(&mut conn).await?;

View file

@ -30,6 +30,7 @@ impl Perform for ListPostReports {
let page = data.page; let page = data.page;
let limit = data.limit; let limit = data.limit;
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let post_reports = PostReportQuery::builder() let post_reports = PostReportQuery::builder()
.conn(&mut conn) .conn(&mut conn)
.my_person_id(person_id) .my_person_id(person_id)

View file

@ -17,6 +17,7 @@ impl Perform for ResolvePostReport {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostReportResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostReportResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &ResolvePostReport = self; let data: &ResolvePostReport = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -22,6 +22,7 @@ impl Perform for MarkPrivateMessageAsRead {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<PrivateMessageResponse, LemmyError> { ) -> Result<PrivateMessageResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &MarkPrivateMessageAsRead = self; let data: &MarkPrivateMessageAsRead = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -23,6 +23,7 @@ impl Perform for CreatePrivateMessageReport {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&self.auth, context).await?; let local_user_view = local_user_view_from_jwt(&self.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?; let local_site = LocalSite::read(&mut conn).await?;

View file

@ -22,6 +22,7 @@ impl Perform for ListPrivateMessageReports {
let page = self.page; let page = self.page;
let limit = self.limit; let limit = self.limit;
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let private_message_reports = PrivateMessageReportQuery::builder() let private_message_reports = PrivateMessageReportQuery::builder()
.conn(&mut conn) .conn(&mut conn)
.unresolved_only(unresolved_only) .unresolved_only(unresolved_only)

View file

@ -16,6 +16,7 @@ impl Perform for ResolvePrivateMessageReport {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&self.auth, context).await?; let local_user_view = local_user_view_from_jwt(&self.auth, context).await?;
is_admin(&local_user_view)?; is_admin(&local_user_view)?;

View file

@ -15,6 +15,7 @@ impl Perform for GetFederatedInstances {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let site_view = SiteView::read_local(&mut conn).await?; let site_view = SiteView::read_local(&mut conn).await?;
let federated_instances = let federated_instances =
build_federated_instances(&site_view.local_site, context.pool()).await?; build_federated_instances(&site_view.local_site, context.pool()).await?;

View file

@ -26,6 +26,7 @@ impl Perform for LeaveAdmin {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<GetSiteResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<GetSiteResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &LeaveAdmin = self; let data: &LeaveAdmin = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -38,6 +38,7 @@ impl Perform for GetModlog {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<GetModlogResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<GetModlogResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &GetModlog = self; let data: &GetModlog = self;
let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await; let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await;

View file

@ -21,6 +21,7 @@ impl Perform for PurgeComment {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &Self = self; let data: &Self = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -22,6 +22,7 @@ impl Perform for PurgeCommunity {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &Self = self; let data: &Self = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -22,6 +22,7 @@ impl Perform for PurgePerson {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &Self = self; let data: &Self = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -22,6 +22,7 @@ impl Perform for PurgePost {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &Self = self; let data: &Self = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -22,6 +22,7 @@ impl Perform for ApproveRegistrationApplication {
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data = self; let data = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -16,6 +16,7 @@ impl Perform for ListRegistrationApplications {
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data = self; let data = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?; let local_site = LocalSite::read(&mut conn).await?;
@ -29,6 +30,7 @@ impl Perform for ListRegistrationApplications {
let page = data.page; let page = data.page;
let limit = data.limit; let limit = data.limit;
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let registration_applications = RegistrationApplicationQuery::builder() let registration_applications = RegistrationApplicationQuery::builder()
.conn(&mut conn) .conn(&mut conn)
.unread_only(unread_only) .unread_only(unread_only)

View file

@ -15,6 +15,7 @@ impl Perform for GetUnreadRegistrationApplicationCount {
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data = self; let data = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?; let local_site = LocalSite::read(&mut conn).await?;

View file

@ -139,6 +139,7 @@ pub async fn local_user_view_from_jwt(
context: &LemmyContext, context: &LemmyContext,
) -> Result<LocalUserView, LemmyError> { ) -> Result<LocalUserView, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let claims = Claims::decode(jwt, &context.secret().jwt_secret) let claims = Claims::decode(jwt, &context.secret().jwt_secret)
.map_err(|e| e.with_message("not_logged_in"))? .map_err(|e| e.with_message("not_logged_in"))?
.claims; .claims;

View file

@ -42,6 +42,7 @@ impl PerformCrud for CreateComment {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommentResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommentResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &CreateComment = self; let data: &CreateComment = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?; let local_site = LocalSite::read(&mut conn).await?;

View file

@ -23,6 +23,7 @@ impl PerformCrud for DeleteComment {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommentResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommentResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &DeleteComment = self; let data: &DeleteComment = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -16,6 +16,7 @@ impl PerformCrud for GetComment {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data = self; let data = self;
let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await; let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await;
let local_site = LocalSite::read(&mut conn).await?; let local_site = LocalSite::read(&mut conn).await?;

View file

@ -24,6 +24,7 @@ impl PerformCrud for RemoveComment {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommentResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommentResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &RemoveComment = self; let data: &RemoveComment = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -32,6 +32,7 @@ impl PerformCrud for EditComment {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommentResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommentResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &EditComment = self; let data: &EditComment = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?; let local_site = LocalSite::read(&mut conn).await?;

View file

@ -47,6 +47,7 @@ impl PerformCrud for CreateCommunity {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommunityResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommunityResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &CreateCommunity = self; let data: &CreateCommunity = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let site_view = SiteView::read_local(&mut conn).await?; let site_view = SiteView::read_local(&mut conn).await?;

View file

@ -20,6 +20,7 @@ impl PerformCrud for DeleteCommunity {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommunityResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommunityResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &DeleteCommunity = self; let data: &DeleteCommunity = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -19,6 +19,7 @@ impl PerformCrud for ListCommunities {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<ListCommunitiesResponse, LemmyError> { ) -> Result<ListCommunitiesResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &ListCommunities = self; let data: &ListCommunities = self;
let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await; let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await;
let local_site = LocalSite::read(&mut conn).await?; let local_site = LocalSite::read(&mut conn).await?;
@ -33,6 +34,7 @@ impl PerformCrud for ListCommunities {
let limit = data.limit; let limit = data.limit;
let local_user = local_user_view.map(|l| l.local_user); let local_user = local_user_view.map(|l| l.local_user);
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let communities = CommunityQuery::builder() let communities = CommunityQuery::builder()
.conn(&mut conn) .conn(&mut conn)
.listing_type(listing_type) .listing_type(listing_type)

View file

@ -22,6 +22,7 @@ impl PerformCrud for RemoveCommunity {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommunityResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommunityResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &RemoveCommunity = self; let data: &RemoveCommunity = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -29,6 +29,7 @@ impl PerformCrud for EditCommunity {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommunityResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommunityResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &EditCommunity = self; let data: &EditCommunity = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?; let local_site = LocalSite::read(&mut conn).await?;

View file

@ -20,6 +20,7 @@ impl PerformCrud for CreateCustomEmoji {
#[tracing::instrument(skip(self, context))] #[tracing::instrument(skip(self, context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CustomEmojiResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<CustomEmojiResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &CreateCustomEmoji = self; let data: &CreateCustomEmoji = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -18,6 +18,7 @@ impl PerformCrud for DeleteCustomEmoji {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<DeleteCustomEmojiResponse, LemmyError> { ) -> Result<DeleteCustomEmojiResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &DeleteCustomEmoji = self; let data: &DeleteCustomEmoji = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -20,6 +20,7 @@ impl PerformCrud for EditCustomEmoji {
#[tracing::instrument(skip(self, context))] #[tracing::instrument(skip(self, context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CustomEmojiResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<CustomEmojiResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &EditCustomEmoji = self; let data: &EditCustomEmoji = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -45,6 +45,7 @@ impl PerformCrud for CreatePost {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &CreatePost = self; let data: &CreatePost = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?; let local_site = LocalSite::read(&mut conn).await?;

View file

@ -19,6 +19,7 @@ impl PerformCrud for DeletePost {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &DeletePost = self; let data: &DeletePost = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -26,6 +26,7 @@ impl PerformCrud for GetPost {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<GetPostResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<GetPostResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &GetPost = self; let data: &GetPost = self;
let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await; let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await;
let local_site = LocalSite::read(&mut conn).await?; let local_site = LocalSite::read(&mut conn).await?;

View file

@ -22,6 +22,7 @@ impl PerformCrud for RemovePost {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &RemovePost = self; let data: &RemovePost = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -31,6 +31,7 @@ impl PerformCrud for EditPost {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &EditPost = self; let data: &EditPost = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?; let local_site = LocalSite::read(&mut conn).await?;

View file

@ -36,6 +36,7 @@ impl PerformCrud for CreatePrivateMessage {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<PrivateMessageResponse, LemmyError> { ) -> Result<PrivateMessageResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &CreatePrivateMessage = self; let data: &CreatePrivateMessage = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?; let local_site = LocalSite::read(&mut conn).await?;

View file

@ -22,6 +22,7 @@ impl PerformCrud for DeletePrivateMessage {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<PrivateMessageResponse, LemmyError> { ) -> Result<PrivateMessageResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &DeletePrivateMessage = self; let data: &DeletePrivateMessage = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -18,6 +18,7 @@ impl PerformCrud for GetPrivateMessages {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<PrivateMessagesResponse, LemmyError> { ) -> Result<PrivateMessagesResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &GetPrivateMessages = self; let data: &GetPrivateMessages = self;
let local_user_view = local_user_view_from_jwt(data.auth.as_ref(), context).await?; let local_user_view = local_user_view_from_jwt(data.auth.as_ref(), context).await?;
let person_id = local_user_view.person.id; let person_id = local_user_view.person.id;

View file

@ -29,6 +29,7 @@ impl PerformCrud for EditPrivateMessage {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<PrivateMessageResponse, LemmyError> { ) -> Result<PrivateMessageResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &EditPrivateMessage = self; let data: &EditPrivateMessage = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?; let local_site = LocalSite::read(&mut conn).await?;

View file

@ -48,6 +48,7 @@ impl PerformCrud for CreateSite {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<SiteResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<SiteResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &CreateSite = self; let data: &CreateSite = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View file

@ -31,6 +31,7 @@ impl PerformCrud for GetSite {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<GetSiteResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<GetSiteResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &GetSite = self; let data: &GetSite = self;
let site_view = SiteView::read_local(&mut conn).await?; let site_view = SiteView::read_local(&mut conn).await?;

View file

@ -45,6 +45,7 @@ impl PerformCrud for EditSite {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<SiteResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<SiteResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &EditSite = self; let data: &EditSite = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?; let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let site_view = SiteView::read_local(&mut conn).await?; let site_view = SiteView::read_local(&mut conn).await?;

View file

@ -44,6 +44,7 @@ impl PerformCrud for Register {
#[tracing::instrument(skip(self, context))] #[tracing::instrument(skip(self, context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<LoginResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<LoginResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &Register = self; let data: &Register = self;
let site_view = SiteView::read_local(&mut conn).await?; let site_view = SiteView::read_local(&mut conn).await?;

View file

@ -152,6 +152,7 @@ impl ActivityHandler for BlockUser {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> { async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, false, context).await?; insert_activity(&self.id, &self, false, false, context).await?;
let expires = self.expires.map(|u| u.naive_local()); let expires = self.expires.map(|u| u.naive_local());
let mod_person = self.actor.dereference(context).await?; let mod_person = self.actor.dereference(context).await?;

View file

@ -139,6 +139,7 @@ impl SendActivity for BanPerson {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).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 person = Person::read(&mut conn, request.person_id).await?;
let site = SiteOrCommunity::Site(SiteView::read_local(&mut conn).await?.site.into()); let site = SiteOrCommunity::Site(SiteView::read_local(&mut conn).await?.site.into());
@ -183,6 +184,7 @@ impl SendActivity for BanFromCommunity {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
let community: ApubCommunity = Community::read(&mut conn, request.community_id) let community: ApubCommunity = Community::read(&mut conn, request.community_id)
.await? .await?

View file

@ -39,6 +39,7 @@ impl UndoBlockUser {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let block = BlockUser::new(target, user, mod_, None, reason, None, context).await?; let block = BlockUser::new(target, user, mod_, None, reason, None, context).await?;
let audience = if let SiteOrCommunity::Community(c) = target { let audience = if let SiteOrCommunity::Community(c) = target {
Some(c.id().into()) Some(c.id().into())
@ -98,6 +99,7 @@ impl ActivityHandler for UndoBlockUser {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> { async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, false, context).await?; insert_activity(&self.id, &self, false, false, context).await?;
let expires = self.object.expires.map(|u| u.naive_local()); let expires = self.object.expires.map(|u| u.naive_local());
let mod_person = self.actor.dereference(context).await?; let mod_person = self.actor.dereference(context).await?;

View file

@ -118,6 +118,7 @@ impl ActivityHandler for CollectionAdd {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> { async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, false, context).await?; insert_activity(&self.id, &self, false, false, context).await?;
let (community, collection_type) = let (community, collection_type) =
Community::get_by_collection_url(&mut conn, &self.target.into()).await?; Community::get_by_collection_url(&mut conn, &self.target.into()).await?;
@ -175,6 +176,7 @@ impl SendActivity for AddModToCommunity {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
let community: ApubCommunity = Community::read(&mut conn, request.community_id) let community: ApubCommunity = Community::read(&mut conn, request.community_id)
.await? .await?
@ -210,6 +212,7 @@ impl SendActivity for FeaturePost {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).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) let community = Community::read(&mut conn, response.post_view.community.id)
.await? .await?

View file

@ -111,6 +111,7 @@ impl ActivityHandler for CollectionRemove {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> { async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, false, context).await?; insert_activity(&self.id, &self, false, false, context).await?;
let (community, collection_type) = let (community, collection_type) =
Community::get_by_collection_url(&mut conn, &self.target.into()).await?; Community::get_by_collection_url(&mut conn, &self.target.into()).await?;

View file

@ -59,6 +59,7 @@ impl ActivityHandler for LockPage {
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), Self::Error> { async fn receive(self, context: &Data<Self::DataType>) -> Result<(), Self::Error> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let form = PostUpdateForm::builder().locked(Some(true)).build(); let form = PostUpdateForm::builder().locked(Some(true)).build();
let post = self.object.dereference(context).await?; let post = self.object.dereference(context).await?;
Post::update(&mut conn, post.id, &form).await?; Post::update(&mut conn, post.id, &form).await?;
@ -96,6 +97,7 @@ impl ActivityHandler for UndoLockPage {
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), Self::Error> { async fn receive(self, context: &Data<Self::DataType>) -> Result<(), Self::Error> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, false, context).await?; insert_activity(&self.id, &self, false, false, context).await?;
let form = PostUpdateForm::builder().locked(Some(false)).build(); let form = PostUpdateForm::builder().locked(Some(false)).build();
let post = self.object.object.dereference(context).await?; let post = self.object.object.dereference(context).await?;
@ -114,6 +116,7 @@ impl SendActivity for LockPost {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
let id = generate_activity_id( let id = generate_activity_id(
LockType::Lock, LockType::Lock,

View file

@ -38,7 +38,8 @@ pub(crate) async fn send_activity_in_community(
is_mod_action: bool, is_mod_action: bool,
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> 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; let mut inboxes = extra_inboxes;
// send to user followers // send to user followers

View file

@ -123,6 +123,7 @@ impl ActivityHandler for Report {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> { async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, true, context).await?; insert_activity(&self.id, &self, false, true, context).await?;
let actor = self.actor.dereference(context).await?; let actor = self.actor.dereference(context).await?;
match self.object.dereference(context).await? { match self.object.dereference(context).await? {

View file

@ -36,6 +36,7 @@ impl SendActivity for EditCommunity {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).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 community = Community::read(&mut conn, request.community_id).await?;
UpdateCommunity::send(community.into(), &local_user_view.person.into(), context).await UpdateCommunity::send(community.into(), &local_user_view.person.into(), context).await
@ -94,6 +95,7 @@ impl ActivityHandler for UpdateCommunity {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> { async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, false, context).await?; insert_activity(&self.id, &self, false, false, context).await?;
let community = self.community(context).await?; let community = self.community(context).await?;
@ -114,6 +116,7 @@ impl SendActivity for HideCommunity {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).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 community = Community::read(&mut conn, request.community_id).await?;
UpdateCommunity::send(community.into(), &local_user_view.person.into(), context).await UpdateCommunity::send(community.into(), &local_user_view.person.into(), context).await

View file

@ -89,7 +89,8 @@ impl CreateOrUpdateNote {
kind: CreateOrUpdateType, kind: CreateOrUpdateType,
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> 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_id = comment.post_id;
let post = Post::read(&mut conn, post_id).await?; let post = Post::read(&mut conn, post_id).await?;
let community_id = post.community_id; let community_id = post.community_id;
@ -168,6 +169,7 @@ impl ActivityHandler for CreateOrUpdateNote {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> { async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, false, context).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 // Need to do this check here instead of Note::from_json because we need the person who
// send the activity, not the comment author. // send the activity, not the comment author.

View file

@ -108,6 +108,7 @@ impl CreateOrUpdatePage {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let post = ApubPost(post.clone()); let post = ApubPost(post.clone());
let community_id = post.community_id; let community_id = post.community_id;
let person: ApubPerson = Person::read(&mut conn, person_id).await?.into(); let person: ApubPerson = Person::read(&mut conn, person_id).await?.into();
@ -180,6 +181,7 @@ impl ActivityHandler for CreateOrUpdatePage {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> { async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, false, context).await?; insert_activity(&self.id, &self, false, false, context).await?;
let post = ApubPost::from_json(self.object, context).await?; let post = ApubPost::from_json(self.object, context).await?;

View file

@ -71,6 +71,7 @@ impl CreateOrUpdateChatMessage {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let recipient_id = private_message.recipient_id; let recipient_id = private_message.recipient_id;
let sender: ApubPerson = Person::read(&mut conn, sender_id).await?.into(); let sender: ApubPerson = Person::read(&mut conn, sender_id).await?.into();
let recipient: ApubPerson = Person::read(&mut conn, recipient_id).await?.into(); let recipient: ApubPerson = Person::read(&mut conn, recipient_id).await?.into();

View file

@ -106,6 +106,7 @@ pub(in crate::activities) async fn receive_remove_action(
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
match DeletableObjects::read_from_db(object, context).await? { match DeletableObjects::read_from_db(object, context).await? {
DeletableObjects::Community(community) => { DeletableObjects::Community(community) => {
if community.local { if community.local {

View file

@ -29,6 +29,7 @@ impl SendActivity for DeleteAccount {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
let actor: ApubPerson = local_user_view.person.into(); let actor: ApubPerson = local_user_view.person.into();
delete_user_account(actor.id, &mut conn, context.settings(), context.client()).await?; 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<Self::DataType>) -> Result<(), LemmyError> { async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, false, context).await?; insert_activity(&self.id, &self, false, false, context).await?;
let actor = self.actor.dereference(context).await?; let actor = self.actor.dereference(context).await?;
delete_user_account(actor.id, &mut conn, context.settings(), context.client()).await?; delete_user_account(actor.id, &mut conn, context.settings(), context.client()).await?;

View file

@ -64,6 +64,7 @@ impl SendActivity for DeletePost {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).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 community = Community::read(&mut conn, response.post_view.community.id).await?;
let deletable = DeletableObjects::Post(response.post_view.post.clone().into()); let deletable = DeletableObjects::Post(response.post_view.post.clone().into());
@ -89,6 +90,7 @@ impl SendActivity for RemovePost {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).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 community = Community::read(&mut conn, response.post_view.community.id).await?;
let deletable = DeletableObjects::Post(response.post_view.post.clone().into()); let deletable = DeletableObjects::Post(response.post_view.post.clone().into());
@ -114,6 +116,7 @@ impl SendActivity for DeleteComment {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let community_id = response.comment_view.community.id; let community_id = response.comment_view.community.id;
let community = Community::read(&mut conn, community_id).await?; let community = Community::read(&mut conn, community_id).await?;
let person = Person::read(&mut conn, response.comment_view.creator.id).await?; let person = Person::read(&mut conn, response.comment_view.creator.id).await?;
@ -133,6 +136,7 @@ impl SendActivity for RemoveComment {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).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 comment = Comment::read(&mut conn, request.comment_id).await?;
let community = Community::read(&mut conn, response.comment_view.community.id).await?; let community = Community::read(&mut conn, response.comment_view.community.id).await?;
@ -179,6 +183,7 @@ impl SendActivity for DeleteCommunity {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).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 community = Community::read(&mut conn, request.community_id).await?;
let deletable = DeletableObjects::Community(community.clone().into()); let deletable = DeletableObjects::Community(community.clone().into());
@ -204,6 +209,7 @@ impl SendActivity for RemoveCommunity {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).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 community = Community::read(&mut conn, request.community_id).await?;
let deletable = DeletableObjects::Community(community.clone().into()); let deletable = DeletableObjects::Community(community.clone().into());
@ -258,6 +264,7 @@ async fn send_apub_delete_private_message(
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let recipient_id = pm.recipient_id; let recipient_id = pm.recipient_id;
let recipient: ApubPerson = Person::read(&mut conn, recipient_id).await?.into(); let recipient: ApubPerson = Person::read(&mut conn, recipient_id).await?.into();
@ -386,6 +393,7 @@ async fn receive_delete_action(
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
match DeletableObjects::read_from_db(object, context).await? { match DeletableObjects::read_from_db(object, context).await? {
DeletableObjects::Community(community) => { DeletableObjects::Community(community) => {
if community.local { if community.local {

View file

@ -98,6 +98,7 @@ impl UndoDelete {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
match DeletableObjects::read_from_db(object, context).await? { match DeletableObjects::read_from_db(object, context).await? {
DeletableObjects::Community(community) => { DeletableObjects::Community(community) => {
if community.local { if community.local {

View file

@ -61,6 +61,7 @@ impl ActivityHandler for AcceptFollow {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> { async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, true, context).await?; insert_activity(&self.id, &self, false, true, context).await?;
let community = self.actor.dereference(context).await?; let community = self.actor.dereference(context).await?;
let person = self.object.actor.dereference(context).await?; let person = self.object.actor.dereference(context).await?;

View file

@ -61,6 +61,7 @@ impl Follow {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let community_follower_form = CommunityFollowerForm { let community_follower_form = CommunityFollowerForm {
community_id: community.id, community_id: community.id,
person_id: actor.id, person_id: actor.id,
@ -105,6 +106,7 @@ impl ActivityHandler for Follow {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> { async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, true, context).await?; insert_activity(&self.id, &self, false, true, context).await?;
let actor = self.actor.dereference(context).await?; let actor = self.actor.dereference(context).await?;
let object = self.object.dereference(context).await?; let object = self.object.dereference(context).await?;
@ -141,6 +143,7 @@ impl SendActivity for BlockCommunity {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).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 community = Community::read(&mut conn, request.community_id).await?;
UndoFollow::send(&local_user_view.person.into(), &community.into(), context).await UndoFollow::send(&local_user_view.person.into(), &community.into(), context).await

View file

@ -26,6 +26,7 @@ impl SendActivity for FollowCommunity {
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
let person = local_user_view.person.clone().into(); let person = local_user_view.person.clone().into();
let community: ApubCommunity = Community::read(&mut conn, request.community_id) let community: ApubCommunity = Community::read(&mut conn, request.community_id)

View file

@ -72,6 +72,7 @@ impl ActivityHandler for UndoFollow {
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> { async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, true, context).await?; insert_activity(&self.id, &self, false, true, context).await?;
let person = self.actor.dereference(context).await?; let person = self.actor.dereference(context).await?;
let object = self.object.object.dereference(context).await?; let object = self.object.object.dereference(context).await?;

View file

@ -54,6 +54,7 @@ pub(crate) async fn verify_person_in_community(
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let person = person_id.dereference(context).await?; let person = person_id.dereference(context).await?;
if person.banned { if person.banned {
return Err(LemmyError::from_message("Person is banned from site")); return Err(LemmyError::from_message("Person is banned from site"));
@ -83,6 +84,7 @@ pub(crate) async fn verify_mod_action(
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let mod_ = mod_id.dereference(context).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?; let is_mod_or_admin = CommunityView::is_mod_or_admin(&mut conn, mod_.id, community_id).await?;

View file

@ -84,6 +84,7 @@ async fn send_activity(
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let community = Community::read(&mut conn, community_id).await?.into(); let community = Community::read(&mut conn, community_id).await?.into();
let local_user_view = local_user_view_from_jwt(jwt, context).await?; let local_user_view = local_user_view_from_jwt(jwt, context).await?;
let actor = Person::read(&mut conn, local_user_view.person.id) let actor = Person::read(&mut conn, local_user_view.person.id)
@ -112,6 +113,7 @@ async fn vote_comment(
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let comment_id = comment.id; let comment_id = comment.id;
let like_form = CommentLikeForm { let like_form = CommentLikeForm {
comment_id, comment_id,
@ -133,6 +135,7 @@ async fn vote_post(
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let post_id = post.id; let post_id = post.id;
let like_form = PostLikeForm { let like_form = PostLikeForm {
post_id: post.id, post_id: post.id,
@ -152,6 +155,7 @@ async fn undo_vote_comment(
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let comment_id = comment.id; let comment_id = comment.id;
let person_id = actor.id; let person_id = actor.id;
CommentLike::remove(&mut conn, person_id, comment_id).await?; CommentLike::remove(&mut conn, person_id, comment_id).await?;
@ -165,6 +169,7 @@ async fn undo_vote_post(
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let post_id = post.id; let post_id = post.id;
let person_id = actor.id; let person_id = actor.id;
PostLike::remove(&mut conn, person_id, post_id).await?; PostLike::remove(&mut conn, person_id, post_id).await?;

View file

@ -23,6 +23,7 @@ impl PerformApub for GetComments {
#[tracing::instrument(skip(context))] #[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<GetCommentsResponse, LemmyError> { async fn perform(&self, context: &Data<LemmyContext>) -> Result<GetCommentsResponse, LemmyError> {
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let data: &GetComments = self; let data: &GetComments = self;
let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await; let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await;
let local_site = LocalSite::read(&mut conn).await?; let local_site = LocalSite::read(&mut conn).await?;
@ -56,6 +57,7 @@ impl PerformApub for GetComments {
let post_id = data.post_id; let post_id = data.post_id;
let local_user = local_user_view.map(|l| l.local_user); let local_user = local_user_view.map(|l| l.local_user);
let mut conn = context.conn().await?; let mut conn = context.conn().await?;
let comments = CommentQuery::builder() let comments = CommentQuery::builder()
.conn(&mut conn) .conn(&mut conn)
.listing_type(Some(listing_type)) .listing_type(Some(listing_type))

Some files were not shown because too many files have changed in this diff Show more