update
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Notifications\UserFollowedNotification;
|
||||
use App\Events\Achievements\AchievementCheckRequested;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
@@ -16,6 +19,8 @@ use Illuminate\Support\Facades\DB;
|
||||
*/
|
||||
final class FollowService
|
||||
{
|
||||
public function __construct(private readonly XPService $xp) {}
|
||||
|
||||
/**
|
||||
* Follow $targetId on behalf of $actorId.
|
||||
*
|
||||
@@ -60,6 +65,15 @@ final class FollowService
|
||||
targetId: $targetId,
|
||||
);
|
||||
} catch (\Throwable) {}
|
||||
|
||||
$targetUser = User::query()->find($targetId);
|
||||
$actorUser = User::query()->find($actorId);
|
||||
if ($targetUser && $actorUser) {
|
||||
$targetUser->notify(new UserFollowedNotification($actorUser));
|
||||
}
|
||||
|
||||
$this->xp->awardFollowerReceived($targetId, $actorId);
|
||||
event(new AchievementCheckRequested($targetId));
|
||||
}
|
||||
|
||||
return $inserted;
|
||||
|
||||
Reference in New Issue
Block a user