From 73556d4c685d48f750c34a426ab3436d826643ac Mon Sep 17 00:00:00 2001 From: Severin Date: Fri, 29 May 2026 20:24:56 +0200 Subject: [PATCH 1/7] Add push notifications within the notification service --- app/Services/NotificationService.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/app/Services/NotificationService.php b/app/Services/NotificationService.php index 3753b06da..50b06d990 100644 --- a/app/Services/NotificationService.php +++ b/app/Services/NotificationService.php @@ -2,8 +2,10 @@ namespace App\Services; +use App\Jobs\PushNotifications\SendPushNotificationJob; use App\Models\Notification; use App\Models\StarterKit; +use App\Services\ConfigService; use Illuminate\Support\Facades\Cache; class NotificationService @@ -68,6 +70,14 @@ public static function newVideoLike($uid, $vid, $pid) ]); self::clearUnreadCount($uid); + if (app(ConfigService::class)->pushNotifications()) { + SendPushNotificationJob::dispatch_newVideoLike( + profileId: $pid, + videoId: $vid, + actorId: $uid, + ); + } + return $res; } @@ -221,6 +231,15 @@ public static function newVideoComment($pid, $uid, $vid, $cid) ]); self::clearUnreadCount($uid); + if (app(ConfigService::class)->pushNotifications()) { + SendPushNotificationJob::dispatch_newVideoComment( + profileId: $pid, + videoId: $vid, + actorId: $uid, + commentId: $cid, + ); + } + return $res; } @@ -262,6 +281,14 @@ public static function newCommentReply($pid, $uid, $vid, $cid, $crid) ]); self::clearUnreadCount($uid); + if (app(ConfigService::class)->pushNotifications()) { + SendPushNotificationJob::dispatch_newVideoCommentReply( + profileId: $pid, + videoId: $vid, + actorId: $uid, + commentId: $cid, + ); + } return $res; } From 44b7c6298c66d5ae5d33507c84482272094f3532 Mon Sep 17 00:00:00 2001 From: Severin Date: Fri, 29 May 2026 20:32:22 +0200 Subject: [PATCH 2/7] Add push notifications to notification service --- app/Services/NotificationService.php | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/app/Services/NotificationService.php b/app/Services/NotificationService.php index 50b06d990..0c163810f 100644 --- a/app/Services/NotificationService.php +++ b/app/Services/NotificationService.php @@ -72,9 +72,9 @@ public static function newVideoLike($uid, $vid, $pid) if (app(ConfigService::class)->pushNotifications()) { SendPushNotificationJob::dispatch_newVideoLike( - profileId: $pid, + profileId: $uid, videoId: $vid, - actorId: $uid, + actorId: $pid, ); } @@ -165,6 +165,12 @@ public static function newFollower($uid, $pid) self::clearUnreadCount($uid); + if (app(ConfigService::class)->pushNotifications()) { + SendPushNotificationJob::dispatch_newFollow( + profileId: $uid, + actorId: $pid, + ); + } return $res; } @@ -233,9 +239,9 @@ public static function newVideoComment($pid, $uid, $vid, $cid) if (app(ConfigService::class)->pushNotifications()) { SendPushNotificationJob::dispatch_newVideoComment( - profileId: $pid, + profileId: $uid, videoId: $vid, - actorId: $uid, + actorId: $pid, commentId: $cid, ); } @@ -283,9 +289,9 @@ public static function newCommentReply($pid, $uid, $vid, $cid, $crid) if (app(ConfigService::class)->pushNotifications()) { SendPushNotificationJob::dispatch_newVideoCommentReply( - profileId: $pid, + profileId: $uid, videoId: $vid, - actorId: $uid, + actorId: $pid, commentId: $cid, ); } @@ -334,6 +340,13 @@ public static function newVideoShare($uid, $vid, $pid) ]); self::clearUnreadCount($uid); + if (app(ConfigService::class)->pushNotifications()) { + SendPushNotificationJob::dispatch_newRepost( + profileId: $uid, + videoId: $vid, + actorId: $pid, + ); + } return $res; } From b7d3ffbd8542b716227e00242ab718db0b5efd46 Mon Sep 17 00:00:00 2001 From: Severin Date: Fri, 29 May 2026 20:37:52 +0200 Subject: [PATCH 3/7] Commenting out push notification jobs from API due to moving it to NotificationService --- app/Http/Controllers/Api/VideoController.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Api/VideoController.php b/app/Http/Controllers/Api/VideoController.php index 03450f40e..33c505d0e 100644 --- a/app/Http/Controllers/Api/VideoController.php +++ b/app/Http/Controllers/Api/VideoController.php @@ -455,7 +455,7 @@ public function like(Request $request, $id) app(LikeService::class)->addVideoLike((string) $video->id, (string) $pid); - if (app(ConfigService::class)->pushNotifications()) { + /*if (app(ConfigService::class)->pushNotifications()) { if ($pid != $video->profile_id && ! $video->uri) { SendPushNotificationJob::dispatch_newVideoLike( profileId: $video->profile_id, @@ -463,7 +463,7 @@ public function like(Request $request, $id) actorId: $pid, ); } - } + }*/ if ($video->uri) { $config = app(ConfigService::class); @@ -635,7 +635,7 @@ public function storeComment(StoreCommentRequest $request, $vid) app(FederationDispatcher::class)->dispatchCommentReplyCreation($comment); } - if ($config->pushNotifications()) { + /*if ($config->pushNotifications()) { if ($pid != $parent->profile_id && $pid != $video->profile_id) { SendPushNotificationJob::dispatch_newVideoCommentReply( profileId: $parent->profile_id, @@ -644,7 +644,7 @@ public function storeComment(StoreCommentRequest $request, $vid) commentId: $comment->id, ); } - } + }*/ } else { $comment = new Comment; $comment->video_id = $vid; @@ -661,7 +661,7 @@ public function storeComment(StoreCommentRequest $request, $vid) app(FederationDispatcher::class)->dispatchCommentCreation($comment); } - if ($config->pushNotifications()) { + /*if ($config->pushNotifications()) { if ($pid != $video->profile_id) { SendPushNotificationJob::dispatch_newVideoComment( profileId: $video->profile_id, @@ -670,7 +670,7 @@ public function storeComment(StoreCommentRequest $request, $vid) commentId: $comment->id, ); } - } + }*/ } $video->recalculateCommentsCount(); @@ -729,14 +729,14 @@ public function storeCommentMedia(StoreCommentMediaRequest $request, $vid) if ($config->federation()) { app(FederationDispatcher::class)->dispatchCommentCreation($comment); } - if ($config->pushNotifications() && $pid != $video->profile_id) { + /*if ($config->pushNotifications() && $pid != $video->profile_id) { SendPushNotificationJob::dispatch_newVideoComment( profileId: $video->profile_id, videoId: $video->id, actorId: $pid, commentId: $comment->id, ); - } + }*/ CommentKlipyMediaShareTriggerJob::dispatch((string) $klipyId, $type, (string) $user->id); From 43a14147c04ed04b7de539695354e698ff31c0a1 Mon Sep 17 00:00:00 2001 From: Severin Date: Fri, 29 May 2026 20:38:33 +0200 Subject: [PATCH 4/7] No need for SendPushnotificationJob in API anymore --- app/Http/Controllers/Api/VideoController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/VideoController.php b/app/Http/Controllers/Api/VideoController.php index 33c505d0e..0e1bc5075 100644 --- a/app/Http/Controllers/Api/VideoController.php +++ b/app/Http/Controllers/Api/VideoController.php @@ -30,7 +30,7 @@ use App\Jobs\Federation\DeliverUndoCommentReplyLikeActivity; use App\Jobs\Federation\DeliverUndoVideoLikeActivity; use App\Jobs\Federation\DeliverVideoLikeActivity; -use App\Jobs\PushNotifications\SendPushNotificationJob; +//use App\Jobs\PushNotifications\SendPushNotificationJob; use App\Jobs\Video\VideoCustomThumbnailJob; use App\Jobs\Video\VideoOptimizeJob; use App\Jobs\Video\VideoProcessingCompleteJob; From 0f46644801b32d890cd1a8315359c1aab38b56e6 Mon Sep 17 00:00:00 2001 From: Severin Date: Fri, 29 May 2026 20:48:46 +0200 Subject: [PATCH 5/7] Update Like notifications to take into account federation and same user likes --- app/Services/NotificationService.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/Services/NotificationService.php b/app/Services/NotificationService.php index 0c163810f..2454fdda9 100644 --- a/app/Services/NotificationService.php +++ b/app/Services/NotificationService.php @@ -70,7 +70,8 @@ public static function newVideoLike($uid, $vid, $pid) ]); self::clearUnreadCount($uid); - if (app(ConfigService::class)->pushNotifications()) { + $video = Video::with('profile_id')->find($vid); + if (app(ConfigService::class)->pushNotifications() && $uid != $video->profile_id && ! $video->uri) { SendPushNotificationJob::dispatch_newVideoLike( profileId: $uid, videoId: $vid, @@ -287,14 +288,6 @@ public static function newCommentReply($pid, $uid, $vid, $cid, $crid) ]); self::clearUnreadCount($uid); - if (app(ConfigService::class)->pushNotifications()) { - SendPushNotificationJob::dispatch_newVideoCommentReply( - profileId: $uid, - videoId: $vid, - actorId: $pid, - commentId: $cid, - ); - } return $res; } @@ -310,6 +303,15 @@ public static function newVideoCommentReply($pid, $uid, $vid, $cid, $crid) ]); self::clearUnreadCount($uid); + if (app(ConfigService::class)->pushNotifications()) { + SendPushNotificationJob::dispatch_newVideoCommentReply( + profileId: $uid, + videoId: $vid, + actorId: $pid, + commentId: $cid, + ); + } + return $res; } From 8b9a58ebc4a628456cdac4de545e4f898b21ece3 Mon Sep 17 00:00:00 2001 From: Severin Date: Fri, 29 May 2026 22:08:52 +0200 Subject: [PATCH 6/7] Add video model --- app/Services/NotificationService.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Services/NotificationService.php b/app/Services/NotificationService.php index 2454fdda9..5484b497b 100644 --- a/app/Services/NotificationService.php +++ b/app/Services/NotificationService.php @@ -5,6 +5,7 @@ use App\Jobs\PushNotifications\SendPushNotificationJob; use App\Models\Notification; use App\Models\StarterKit; +use App\Models\Video; use App\Services\ConfigService; use Illuminate\Support\Facades\Cache; @@ -70,8 +71,8 @@ public static function newVideoLike($uid, $vid, $pid) ]); self::clearUnreadCount($uid); - $video = Video::with('profile_id')->find($vid); - if (app(ConfigService::class)->pushNotifications() && $uid != $video->profile_id && ! $video->uri) { + $video = Video::find($vid); + if (app(ConfigService::class)->pushNotifications() && $pid != $video->profile_id && ! $video->uri) { SendPushNotificationJob::dispatch_newVideoLike( profileId: $uid, videoId: $vid, From 9b17f65f15bd7e3b35d20c66bbdfa50a47577eea Mon Sep 17 00:00:00 2001 From: Severin Date: Fri, 29 May 2026 22:39:25 +0200 Subject: [PATCH 7/7] Lint --- app/Services/NotificationService.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Services/NotificationService.php b/app/Services/NotificationService.php index 5484b497b..9db7026ba 100644 --- a/app/Services/NotificationService.php +++ b/app/Services/NotificationService.php @@ -79,7 +79,7 @@ public static function newVideoLike($uid, $vid, $pid) actorId: $pid, ); } - + return $res; } @@ -173,6 +173,7 @@ public static function newFollower($uid, $pid) actorId: $pid, ); } + return $res; } @@ -247,7 +248,7 @@ public static function newVideoComment($pid, $uid, $vid, $cid) commentId: $cid, ); } - + return $res; } @@ -312,7 +313,7 @@ public static function newVideoCommentReply($pid, $uid, $vid, $cid, $crid) commentId: $cid, ); } - + return $res; } @@ -350,6 +351,7 @@ public static function newVideoShare($uid, $vid, $pid) actorId: $pid, ); } + return $res; }