diff --git a/CHANGELOG.md b/CHANGELOG.md index becf2298d..591025bfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -96,6 +96,8 @@ - Update AP helpers, more efficently update post count ([7caed381](https://github.com/pixelfed/pixelfed/commit/7caed381)) - Update AP helpers, refactor post count decrement logic ([b81ae577](https://github.com/pixelfed/pixelfed/commit/b81ae577)) - Update AP helpers, fix sensitive bug ([00ed330c](https://github.com/pixelfed/pixelfed/commit/00ed330c)) +- Update NotificationEpochUpdatePipeline, use more efficient query ([4d401389](https://github.com/pixelfed/pixelfed/commit/4d401389)) +- Update notification pipelines, fix non-local saving ([fa97a1f3](https://github.com/pixelfed/pixelfed/commit/fa97a1f3)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.9 (2023-08-21)](https://github.com/pixelfed/pixelfed/compare/v0.11.8...v0.11.9) diff --git a/app/Jobs/CommentPipeline/CommentPipeline.php b/app/Jobs/CommentPipeline/CommentPipeline.php index 3b2d896af..1917ecea5 100644 --- a/app/Jobs/CommentPipeline/CommentPipeline.php +++ b/app/Jobs/CommentPipeline/CommentPipeline.php @@ -91,19 +91,21 @@ class CommentPipeline implements ShouldQueue return; } - DB::transaction(function() use($target, $actor, $comment) { - $notification = new Notification(); - $notification->profile_id = $target->id; - $notification->actor_id = $actor->id; - $notification->action = 'comment'; - $notification->item_id = $comment->id; - $notification->item_type = "App\Status"; - $notification->save(); - - NotificationService::setNotification($notification); - NotificationService::set($notification->profile_id, $notification->id); - StatusService::del($comment->id); - }); + if($target->user_id && $target->domain === null) { + DB::transaction(function() use($target, $actor, $comment) { + $notification = new Notification(); + $notification->profile_id = $target->id; + $notification->actor_id = $actor->id; + $notification->action = 'comment'; + $notification->item_id = $comment->id; + $notification->item_type = "App\Status"; + $notification->save(); + + NotificationService::setNotification($notification); + NotificationService::set($notification->profile_id, $notification->id); + StatusService::del($comment->id); + }); + } if($exists = Cache::get('status:replies:all:' . $status->id)) { if($exists && $exists->count() == 3) { diff --git a/app/Jobs/FollowPipeline/FollowPipeline.php b/app/Jobs/FollowPipeline/FollowPipeline.php index 225334304..67733919f 100644 --- a/app/Jobs/FollowPipeline/FollowPipeline.php +++ b/app/Jobs/FollowPipeline/FollowPipeline.php @@ -72,16 +72,18 @@ class FollowPipeline implements ShouldQueue $target->save(); AccountService::del($target->id); - try { - $notification = new Notification(); - $notification->profile_id = $target->id; - $notification->actor_id = $actor->id; - $notification->action = 'follow'; - $notification->item_id = $target->id; - $notification->item_type = "App\Profile"; - $notification->save(); - } catch (Exception $e) { - Log::error($e); + if($target->user_id && $target->domain === null) { + try { + $notification = new Notification(); + $notification->profile_id = $target->id; + $notification->actor_id = $actor->id; + $notification->action = 'follow'; + $notification->item_id = $target->id; + $notification->item_type = "App\Profile"; + $notification->save(); + } catch (Exception $e) { + Log::error($e); + } } } } diff --git a/app/Jobs/InternalPipeline/NotificationEpochUpdatePipeline.php b/app/Jobs/InternalPipeline/NotificationEpochUpdatePipeline.php index 477b1f9b3..79df5aa9a 100644 --- a/app/Jobs/InternalPipeline/NotificationEpochUpdatePipeline.php +++ b/app/Jobs/InternalPipeline/NotificationEpochUpdatePipeline.php @@ -61,7 +61,12 @@ class NotificationEpochUpdatePipeline implements ShouldQueue, ShouldBeUniqueUnti */ public function handle(): void { - $rec = Notification::where('created_at', '>', now()->subMonths(6))->first(); + $pid = Cache::get(NotificationService::EPOCH_CACHE_KEY . '6'); + if($pid && $pid > 1) { + $rec = Notification::where('id', '>', $pid)->whereDate('created_at', now()->subMonths(6)->format('Y-m-d'))->first(); + } else { + $rec = Notification::whereDate('created_at', now()->subMonths(6)->format('Y-m-d'))->first(); + } $id = 1; if($rec) { $id = $rec->id; diff --git a/app/Jobs/LikePipeline/LikePipeline.php b/app/Jobs/LikePipeline/LikePipeline.php index b44c90c8b..e55c64f80 100644 --- a/app/Jobs/LikePipeline/LikePipeline.php +++ b/app/Jobs/LikePipeline/LikePipeline.php @@ -79,16 +79,18 @@ class LikePipeline implements ShouldQueue return true; } - try { - $notification = new Notification(); - $notification->profile_id = $status->profile_id; - $notification->actor_id = $actor->id; - $notification->action = 'like'; - $notification->item_id = $status->id; - $notification->item_type = "App\Status"; - $notification->save(); - - } catch (Exception $e) { + if($status->uri === null && $status->object_url === null && $status->url === null) { + try { + $notification = new Notification(); + $notification->profile_id = $status->profile_id; + $notification->actor_id = $actor->id; + $notification->action = 'like'; + $notification->item_id = $status->id; + $notification->item_type = "App\Status"; + $notification->save(); + + } catch (Exception $e) { + } } } diff --git a/app/Jobs/StatusPipeline/StatusReplyPipeline.php b/app/Jobs/StatusPipeline/StatusReplyPipeline.php index 35238d293..d8af7b96b 100644 --- a/app/Jobs/StatusPipeline/StatusReplyPipeline.php +++ b/app/Jobs/StatusPipeline/StatusReplyPipeline.php @@ -87,18 +87,20 @@ class StatusReplyPipeline implements ShouldQueue Cache::forget('status:replies:all:' . $reply->id); Cache::forget('status:replies:all:' . $status->id); - DB::transaction(function() use($target, $actor, $status) { - $notification = new Notification(); - $notification->profile_id = $target->id; - $notification->actor_id = $actor->id; - $notification->action = 'comment'; - $notification->item_id = $status->id; - $notification->item_type = "App\Status"; - $notification->save(); - - NotificationService::setNotification($notification); - NotificationService::set($notification->profile_id, $notification->id); - }); + if($target->user_id && $target->domain === null) { + DB::transaction(function() use($target, $actor, $status) { + $notification = new Notification(); + $notification->profile_id = $target->id; + $notification->actor_id = $actor->id; + $notification->action = 'comment'; + $notification->item_id = $status->id; + $notification->item_type = "App\Status"; + $notification->save(); + + NotificationService::setNotification($notification); + NotificationService::set($notification->profile_id, $notification->id); + }); + } if($exists = Cache::get('status:replies:all:' . $reply->id)) { if($exists && $exists->count() == 3) {