From e092917752ab6cc1bae27a2b012d43b248aa7ed0 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 30 Aug 2025 05:26:19 -0600 Subject: [PATCH] Update StoryIndexService, fix markSeen method --- app/Services/StoryIndexService.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Services/StoryIndexService.php b/app/Services/StoryIndexService.php index 393e3d508..ef18302dc 100644 --- a/app/Services/StoryIndexService.php +++ b/app/Services/StoryIndexService.php @@ -2,7 +2,6 @@ namespace App\Services; -use Carbon\CarbonImmutable; use Illuminate\Support\Arr; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; @@ -106,11 +105,14 @@ class StoryIndexService $key = $this->seenKey($viewerId, $authorId); Redis::sadd($key, (string) $storyId); - $expiresAt = CarbonImmutable::instance($storyCreatedAt)->addSeconds(self::STORY_TTL); - $ttl = max(1, $expiresAt->diffInSeconds(now())); + $expiresAt = now()->parse($storyCreatedAt)->addSeconds(self::STORY_TTL); + $secondsUntilExpiry = $expiresAt->getTimestamp() - time(); + $ttl = max(1, $secondsUntilExpiry); $currentTtl = Redis::ttl($key); - $currentTtl = ($currentTtl < 0) ? 0 : $currentTtl; + if ($currentTtl < 0) { + $currentTtl = 0; + } $finalTtl = max($ttl, $currentTtl);