This commit is contained in:
2026-03-20 21:17:26 +01:00
parent 1a62fcb81d
commit 29c3ff8572
229 changed files with 13147 additions and 2577 deletions

View File

@@ -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;