feat: ship creator journey v2 and profile updates

This commit is contained in:
2026-04-12 21:42:07 +02:00
parent a2457f4e49
commit d5cff21ea2
335 changed files with 20147 additions and 1545 deletions

View File

@@ -10,8 +10,11 @@ use App\Jobs\RecComputeSimilarByTagsJob;
use App\Jobs\RecComputeSimilarHybridJob;
use App\Jobs\Posts\AutoUploadPostJob;
use App\Services\ArtworkSearchIndexer;
use App\Services\HomepageService;
use App\Services\Profile\CreatorJourneyService;
use App\Services\UserStatsService;
use App\Services\XPService;
use Illuminate\Support\Facades\Cache;
/**
* Syncs artwork documents to Meilisearch on every relevant model event.
@@ -25,6 +28,8 @@ class ArtworkObserver
private readonly ArtworkSearchIndexer $indexer,
private readonly UserStatsService $userStats,
private readonly XPService $xp,
private readonly HomepageService $homepage,
private readonly CreatorJourneyService $journeys,
) {}
/** New artwork created — index; bump uploadscount + last_upload_at. */
@@ -33,6 +38,11 @@ class ArtworkObserver
$this->indexer->index($artwork);
$this->userStats->incrementUploads($artwork->user_id);
$this->userStats->setLastUploadAt($artwork->user_id, $artwork->created_at);
$this->journeys->requestRebuild((int) $artwork->user_id);
if ($artwork->is_public && $artwork->is_approved && $artwork->published_at !== null) {
$this->bumpExploreCacheVersion();
}
if ($artwork->published_at !== null) {
$this->xp->awardArtworkPublished((int) $artwork->user_id, (int) $artwork->id);
@@ -75,6 +85,18 @@ class ArtworkObserver
}
}
}
if ($this->shouldClearFeaturedCaches($artwork)) {
$this->homepage->clearFeaturedAndMedalCaches();
}
if ($artwork->wasChanged(['published_at', 'is_public', 'is_approved', 'deleted_at'])) {
$this->bumpExploreCacheVersion();
}
if ($artwork->wasChanged(['published_at', 'is_public', 'is_approved', 'visibility', 'deleted_at', 'published_as_type', 'published_as_id'])) {
$this->journeys->requestRebuild((int) $artwork->user_id);
}
}
/** Soft delete — remove from search and decrement uploads_count. */
@@ -82,12 +104,20 @@ class ArtworkObserver
{
$this->indexer->delete($artwork->id);
$this->userStats->decrementUploads($artwork->user_id);
$this->journeys->requestRebuild((int) $artwork->user_id);
$this->bumpExploreCacheVersion();
if ($artwork->features()->exists()) {
$this->homepage->clearFeaturedAndMedalCaches();
}
}
/** Force delete — ensure removal from index; only decrement if NOT already soft-deleted. */
public function forceDeleted(Artwork $artwork): void
{
$this->indexer->delete($artwork->id);
$this->journeys->requestRebuild((int) $artwork->user_id);
$this->bumpExploreCacheVersion();
// If deleted_at was null the artwork was not soft-deleted before;
// the deleted() event did NOT fire, so we decrement here.
@@ -101,5 +131,25 @@ class ArtworkObserver
{
$this->indexer->index($artwork);
$this->userStats->incrementUploads($artwork->user_id);
$this->journeys->requestRebuild((int) $artwork->user_id);
$this->bumpExploreCacheVersion();
if ($artwork->features()->exists()) {
$this->homepage->clearFeaturedAndMedalCaches();
}
}
private function bumpExploreCacheVersion(): void
{
Cache::forever('explore.cache.version', ((int) Cache::get('explore.cache.version', 1)) + 1);
}
private function shouldClearFeaturedCaches(Artwork $artwork): bool
{
if (! $artwork->wasChanged(['published_at', 'is_public', 'is_approved', 'deleted_at', 'has_missing_thumbnails'])) {
return false;
}
return $artwork->features()->exists();
}
}