feat: ship creator journey v2 and profile updates
This commit is contained in:
@@ -5,6 +5,8 @@ declare(strict_types=1);
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\ArtworkComment;
|
||||
use App\Services\ArtworkStatsService;
|
||||
use App\Services\Profile\CreatorJourneyService;
|
||||
use App\Services\UserStatsService;
|
||||
use App\Services\UserMentionSyncService;
|
||||
use App\Services\XPService;
|
||||
@@ -17,7 +19,9 @@ use Illuminate\Support\Facades\DB;
|
||||
class ArtworkCommentObserver
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ArtworkStatsService $artworkStats,
|
||||
private readonly UserStatsService $userStats,
|
||||
private readonly CreatorJourneyService $journeys,
|
||||
private readonly UserMentionSyncService $mentionSync,
|
||||
private readonly XPService $xp,
|
||||
) {}
|
||||
@@ -27,6 +31,7 @@ class ArtworkCommentObserver
|
||||
$creatorId = $this->creatorId($comment->artwork_id);
|
||||
if ($creatorId) {
|
||||
$this->userStats->incrementCommentsReceived($creatorId);
|
||||
$this->journeys->requestRebuild($creatorId);
|
||||
}
|
||||
|
||||
// The commenter is "active"
|
||||
@@ -34,6 +39,7 @@ class ArtworkCommentObserver
|
||||
$this->userStats->setLastActiveAt($comment->user_id);
|
||||
$this->xp->awardCommentCreated((int) $comment->user_id, (int) $comment->id, 'artwork');
|
||||
$this->mentionSync->syncForComment($comment);
|
||||
$this->artworkStats->syncEngagementCounts((int) $comment->artwork_id);
|
||||
}
|
||||
|
||||
public function updated(ArtworkComment $comment): void
|
||||
@@ -49,9 +55,11 @@ class ArtworkCommentObserver
|
||||
$creatorId = $this->creatorId($comment->artwork_id);
|
||||
if ($creatorId) {
|
||||
$this->userStats->decrementCommentsReceived($creatorId);
|
||||
$this->journeys->requestRebuild($creatorId);
|
||||
}
|
||||
|
||||
$this->mentionSync->deleteForComment((int) $comment->id);
|
||||
$this->artworkStats->syncEngagementCounts((int) $comment->artwork_id);
|
||||
}
|
||||
|
||||
/** Hard delete after soft delete — already decremented; nothing to do. */
|
||||
@@ -63,15 +71,23 @@ class ArtworkCommentObserver
|
||||
$creatorId = $this->creatorId($comment->artwork_id);
|
||||
if ($creatorId) {
|
||||
$this->userStats->decrementCommentsReceived($creatorId);
|
||||
$this->journeys->requestRebuild($creatorId);
|
||||
}
|
||||
}
|
||||
|
||||
$this->mentionSync->deleteForComment((int) $comment->id);
|
||||
$this->artworkStats->syncEngagementCounts((int) $comment->artwork_id);
|
||||
}
|
||||
|
||||
public function restored(ArtworkComment $comment): void
|
||||
{
|
||||
$this->mentionSync->syncForComment($comment);
|
||||
$this->artworkStats->syncEngagementCounts((int) $comment->artwork_id);
|
||||
|
||||
$creatorId = $this->creatorId($comment->artwork_id);
|
||||
if ($creatorId) {
|
||||
$this->journeys->requestRebuild($creatorId);
|
||||
}
|
||||
}
|
||||
|
||||
private function creatorId(int $artworkId): ?int
|
||||
|
||||
Reference in New Issue
Block a user