Update FollowPipeline

This commit is contained in:
Daniel Supernault 2024-09-30 04:45:36 -06:00
parent bd96840587
commit 7b4256549a
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1

View file

@ -3,7 +3,13 @@
namespace App\Jobs\FollowPipeline;
use App\Follower;
use App\Jobs\PushNotificationPipeline\FollowPushNotifyPipeline;
use App\Notification;
use App\Services\AccountService;
use App\Services\FollowerService;
use App\Services\NotificationAppGatewayService;
use App\Services\PushNotificationService;
use App\User;
use Cache;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@ -11,9 +17,6 @@ use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Log;
use Illuminate\Support\Facades\Redis;
use App\Services\AccountService;
use App\Services\FollowerService;
class FollowPipeline implements ShouldQueue
{
@ -74,7 +77,7 @@ class FollowPipeline implements ShouldQueue
if ($target->user_id && $target->domain === null) {
try {
$notification = new Notification();
$notification = new Notification;
$notification->profile_id = $target->id;
$notification->actor_id = $actor->id;
$notification->action = 'follow';
@ -84,6 +87,15 @@ class FollowPipeline implements ShouldQueue
} catch (Exception $e) {
Log::error($e);
}
if (NotificationAppGatewayService::enabled()) {
if (PushNotificationService::check('follow', $target->id)) {
$user = User::whereProfileId($target->id)->first();
if ($user && $user->expo_token && $user->notify_enabled) {
FollowPushNotifyPipeline::dispatchSync($user->expo_token, $actor->username);
}
}
}
}
}
}