From 2c2e8bcabdec04ee83259733864678545ac1f21b Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Fri, 15 May 2026 17:51:08 +0530 Subject: [PATCH] fix: add expiration check for presence updates to prevent outdated entries --- src/Appwrite/Platform/Modules/Presences/HTTP/Update.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Appwrite/Platform/Modules/Presences/HTTP/Update.php b/src/Appwrite/Platform/Modules/Presences/HTTP/Update.php index 5d2159daa2..fcd76d0fbc 100644 --- a/src/Appwrite/Platform/Modules/Presences/HTTP/Update.php +++ b/src/Appwrite/Platform/Modules/Presences/HTTP/Update.php @@ -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) {