From d97383c0f6382d12b374ee39060b31ff1bf6f20e Mon Sep 17 00:00:00 2001 From: Anil Kulkarni <6687139+intentionally-left-nil@users.noreply.github.com> Date: Sat, 25 Jan 2025 20:27:20 -0800 Subject: [PATCH] Fix the local column for statuses to not include remote shares (#5513) * Fix the local column for statuses to not include remote shares * Chunk the migration --- app/Util/ActivityPub/Inbox.php | 1 + .../2025_01_18_061532_fix_local_statuses.php | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 database/migrations/2025_01_18_061532_fix_local_statuses.php diff --git a/app/Util/ActivityPub/Inbox.php b/app/Util/ActivityPub/Inbox.php index e98b48c49..ddd377a70 100644 --- a/app/Util/ActivityPub/Inbox.php +++ b/app/Util/ActivityPub/Inbox.php @@ -645,6 +645,7 @@ class Inbox 'profile_id' => $actor->id, 'reblog_of_id' => $parent->id, 'type' => 'share', + 'local' => false, ]); Notification::firstOrCreate( diff --git a/database/migrations/2025_01_18_061532_fix_local_statuses.php b/database/migrations/2025_01_18_061532_fix_local_statuses.php new file mode 100644 index 000000000..f17eeaa0f --- /dev/null +++ b/database/migrations/2025_01_18_061532_fix_local_statuses.php @@ -0,0 +1,31 @@ +where('local', true) + ->where('type', 'share') + ->whereHas('profile', function($query) { + $query->whereDoesntHave('user'); + }) + ->chunkById(100, function($statuses) { + foreach($statuses as $status) { + $status->local = false; + $status->save(); + } + }); + } + + public function down(): void + { + // No down migration needed since this is a data fix + } +};