From 2c06e4185f97cff54c38adff3cfcb66eab817675 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Thu, 30 Apr 2026 13:30:25 +0530 Subject: [PATCH] Update presence expiry datetime validation to enforce a 30-day maximum limit. This change standardizes the 'expiresAt' parameter across the Update and Upsert actions, ensuring consistent handling of presence expiry across the API. --- src/Appwrite/Platform/Modules/Presences/HTTP/Update.php | 6 +++++- src/Appwrite/Platform/Modules/Presences/HTTP/Upsert.php | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Presences/HTTP/Update.php b/src/Appwrite/Platform/Modules/Presences/HTTP/Update.php index 8e4025e9f2..cb20fb601d 100644 --- a/src/Appwrite/Platform/Modules/Presences/HTTP/Update.php +++ b/src/Appwrite/Platform/Modules/Presences/HTTP/Update.php @@ -92,7 +92,11 @@ class Update extends PlatformAction ->param('presenceId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Presence unique ID.', false, ['dbForProject']) ->param('userId', null, new Nullable(new UID()), 'User ID.', true) ->param('status', null, new Nullable(new Text(Database::LENGTH_KEY)), 'Presence status.', true) - ->param('expiresAt', null, new Nullable(new DatetimeValidator()), 'Presence expiry datetime.', true) + ->param('expiresAt', null, new Nullable(new DatetimeValidator( + new \DateTime(), + (new \DateTime())->modify('+30 days'), + requireDateInFuture: true + )), 'Presence expiry datetime.', true) ->param('metadata', null, new Nullable(new JSON()), 'Presence metadata object.', true) ->param('permissions', null, new Nullable(new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE, [Database::PERMISSION_READ, Database::PERMISSION_UPDATE, Database::PERMISSION_DELETE, Database::PERMISSION_WRITE])), 'An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) ->inject('response') diff --git a/src/Appwrite/Platform/Modules/Presences/HTTP/Upsert.php b/src/Appwrite/Platform/Modules/Presences/HTTP/Upsert.php index 5908e52111..8297639045 100644 --- a/src/Appwrite/Platform/Modules/Presences/HTTP/Upsert.php +++ b/src/Appwrite/Platform/Modules/Presences/HTTP/Upsert.php @@ -96,8 +96,11 @@ class Upsert extends PlatformAction ->param('userId', null, new Nullable(new UID()), 'User ID.', true) ->param('status', '', new Text(Database::LENGTH_KEY), 'Presence status.', false) ->param('permissions', null, new Nullable(new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE, [Database::PERMISSION_READ, Database::PERMISSION_UPDATE, Database::PERMISSION_DELETE, Database::PERMISSION_WRITE])), 'An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) - // TODO: what shall be the min and max date here - ->param('expiresAt', null, new Nullable(new DatetimeValidator(requireDateInFuture: true)), 'Presence expiry datetime.', true) + ->param('expiresAt', null, new Nullable(new DatetimeValidator( + new \DateTime(), + (new \DateTime())->modify('+30 days'), + requireDateInFuture: true + )), 'Presence expiry datetime.', true) ->param('metadata', [], new JSON(), 'Presence metadata object.', true) ->inject('response') ->inject('request')