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) {