Browse Source

Merge pull request #4822 from pixelfed/staging

Update Inbox, improve tombstone query efficiency
daniel 1 year ago
parent
commit
a5a2f77871
2 changed files with 10 additions and 7 deletions
  1. 1 0
      CHANGELOG.md
  2. 9 7
      app/Util/ActivityPub/Inbox.php

+ 1 - 0
CHANGELOG.md

@@ -77,6 +77,7 @@
 - Update PhotoAlbumPresenter.vue, fix fullscreen mode ([822e9888](https://github.com/pixelfed/pixelfed/commit/822e9888))
 - Update Timeline.vue, improve CHT pagination ([9c43e7e2](https://github.com/pixelfed/pixelfed/commit/9c43e7e2))
 - Update HomeFeedPipeline, fix StatusService validation ([041c0135](https://github.com/pixelfed/pixelfed/commit/041c0135))
+- Update Inbox, improve tombstone query efficiency ([759a4393](https://github.com/pixelfed/pixelfed/commit/759a4393))
 -  ([](https://github.com/pixelfed/pixelfed/commit/))
 
 ## [v0.11.9 (2023-08-21)](https://github.com/pixelfed/pixelfed/compare/v0.11.8...v0.11.9)

+ 9 - 7
app/Util/ActivityPub/Inbox.php

@@ -404,7 +404,7 @@ class Inbox
         $status->uri = $activity['id'];
         $status->object_url = $activity['id'];
         $status->in_reply_to_profile_id = $profile->id;
-        $status->save();
+        $status->saveQuietly();
 
         $dm = new DirectMessage;
         $dm->to_id = $profile->id;
@@ -704,13 +704,15 @@ class Inbox
                         if(!$profile || $profile->private_key != null) {
                             return;
                         }
-                        $status = Status::whereProfileId($profile->id)
-                            ->where(function($q) use($id) {
-                                return $q->where('object_url', $id)
-                                    ->orWhere('url', $id);
-                            })
-                            ->first();
+
+                        $status = Status::where('object_url', $id)->first();
                         if(!$status) {
+                            $status = Status::where('url', $id)->first();
+                            if(!$status) {
+                                return;
+                            }
+                        }
+                        if($status->profile_id != $profile->id) {
                             return;
                         }
                         if($status->scope && in_array($status->scope, ['public', 'unlisted', 'private'])) {