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

@@ -7,6 +7,7 @@ namespace App\Observers;
use App\Models\ArtworkComment;
use App\Services\UserStatsService;
use App\Services\UserMentionSyncService;
use App\Services\XPService;
use Illuminate\Support\Facades\DB;
/**
@@ -18,6 +19,7 @@ class ArtworkCommentObserver
public function __construct(
private readonly UserStatsService $userStats,
private readonly UserMentionSyncService $mentionSync,
private readonly XPService $xp,
) {}
public function created(ArtworkComment $comment): void
@@ -30,6 +32,7 @@ class ArtworkCommentObserver
// The commenter is "active"
$this->userStats->ensureRow($comment->user_id);
$this->userStats->setLastActiveAt($comment->user_id);
$this->xp->awardCommentCreated((int) $comment->user_id, (int) $comment->id, 'artwork');
$this->mentionSync->syncForComment($comment);
}

View File

@@ -4,12 +4,14 @@ declare(strict_types=1);
namespace App\Observers;
use App\Events\Achievements\AchievementCheckRequested;
use App\Models\Artwork;
use App\Jobs\RecComputeSimilarByTagsJob;
use App\Jobs\RecComputeSimilarHybridJob;
use App\Jobs\Posts\AutoUploadPostJob;
use App\Services\ArtworkSearchIndexer;
use App\Services\UserStatsService;
use App\Services\XPService;
/**
* Syncs artwork documents to Meilisearch on every relevant model event.
@@ -22,6 +24,7 @@ class ArtworkObserver
public function __construct(
private readonly ArtworkSearchIndexer $indexer,
private readonly UserStatsService $userStats,
private readonly XPService $xp,
) {}
/** New artwork created — index; bump uploadscount + last_upload_at. */
@@ -30,6 +33,11 @@ class ArtworkObserver
$this->indexer->index($artwork);
$this->userStats->incrementUploads($artwork->user_id);
$this->userStats->setLastUploadAt($artwork->user_id, $artwork->created_at);
if ($artwork->published_at !== null) {
$this->xp->awardArtworkPublished((int) $artwork->user_id, (int) $artwork->id);
event(new AchievementCheckRequested((int) $artwork->user_id));
}
}
/** Artwork updated — covers publish, approval, metadata changes. */
@@ -52,6 +60,9 @@ class ArtworkObserver
// Auto-upload post: fire only when artwork transitions to published for the first time
if ($artwork->wasChanged('published_at') && $artwork->published_at !== null) {
$this->xp->awardArtworkPublished((int) $artwork->user_id, (int) $artwork->id);
event(new AchievementCheckRequested((int) $artwork->user_id));
$user = $artwork->user;
$autoPost = $user?->profile?->auto_post_upload ?? true;
if ($autoPost) {