diff --git a/app/Http/Controllers/Api/VideoController.php b/app/Http/Controllers/Api/VideoController.php index 03450f40e..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; @@ -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); diff --git a/app/Services/NotificationService.php b/app/Services/NotificationService.php index 3753b06da..9db7026ba 100644 --- a/app/Services/NotificationService.php +++ b/app/Services/NotificationService.php @@ -2,8 +2,11 @@ namespace App\Services; +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; class NotificationService @@ -68,6 +71,15 @@ public static function newVideoLike($uid, $vid, $pid) ]); self::clearUnreadCount($uid); + $video = Video::find($vid); + if (app(ConfigService::class)->pushNotifications() && $pid != $video->profile_id && ! $video->uri) { + SendPushNotificationJob::dispatch_newVideoLike( + profileId: $uid, + videoId: $vid, + actorId: $pid, + ); + } + return $res; } @@ -155,6 +167,13 @@ public static function newFollower($uid, $pid) self::clearUnreadCount($uid); + if (app(ConfigService::class)->pushNotifications()) { + SendPushNotificationJob::dispatch_newFollow( + profileId: $uid, + actorId: $pid, + ); + } + return $res; } @@ -221,6 +240,15 @@ public static function newVideoComment($pid, $uid, $vid, $cid) ]); self::clearUnreadCount($uid); + if (app(ConfigService::class)->pushNotifications()) { + SendPushNotificationJob::dispatch_newVideoComment( + profileId: $uid, + videoId: $vid, + actorId: $pid, + commentId: $cid, + ); + } + return $res; } @@ -277,6 +305,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; } @@ -307,6 +344,14 @@ 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; }