fix: add expiration check for presence updates to prevent outdated entries

This commit is contained in:
ArnabChatterjee20k
2026-05-15 17:51:08 +05:30
parent a8670ee8fb
commit 2c2e8bcabd
@@ -13,6 +13,7 @@ use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Database\Documents\User;
use Appwrite\Utopia\Response;
use Utopia\Database\Database;
use Utopia\Database\DateTime;
use Utopia\Database\Document;
use Utopia\Database\Exception\Conflict as ConflictException;
use Utopia\Database\Exception\Duplicate;
@@ -138,6 +139,11 @@ class Update extends PlatformAction
throw new Exception(Exception::PRESENCE_NOT_FOUND, params: [$presenceId]);
}
$presenceExpiresAt = $presence->getAttribute('expiresAt');
if (!empty($presenceExpiresAt) && DateTime::formatTz($presenceExpiresAt) < DateTime::formatTz(DateTime::now())) {
throw new Exception(Exception::PRESENCE_NOT_FOUND, params: [$presenceId]);
}
$updateData = [];
if ($userId !== null) {