Update StoryIndexService, fix markSeen method

pull/6134/head
Daniel Supernault 3 months ago
parent 3296a7a583
commit e092917752
No known key found for this signature in database
GPG Key ID: 23740873EE6F76A1

@ -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);

Loading…
Cancel
Save