From 3296a7a583af4293e736751f841fe7daaaa657a2 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 30 Aug 2025 05:06:31 -0600 Subject: [PATCH] Update StoryIndexService, improve markSeen handling --- app/Services/StoryIndexService.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Services/StoryIndexService.php b/app/Services/StoryIndexService.php index 9349afe82..393e3d508 100644 --- a/app/Services/StoryIndexService.php +++ b/app/Services/StoryIndexService.php @@ -107,8 +107,14 @@ class StoryIndexService Redis::sadd($key, (string) $storyId); $expiresAt = CarbonImmutable::instance($storyCreatedAt)->addSeconds(self::STORY_TTL); - $ttl = max(1, $expiresAt->diffInSeconds(now(), false) * -1); - Redis::expire($key, max($ttl, (int) Redis::ttl($key))); + $ttl = max(1, $expiresAt->diffInSeconds(now())); + + $currentTtl = Redis::ttl($key); + $currentTtl = ($currentTtl < 0) ? 0 : $currentTtl; + + $finalTtl = max($ttl, $currentTtl); + + Redis::expire($key, $finalTtl); } public function rebuildIndex(): array