From 7d3ebe73046d9875d52ed73545f4fc26c25732fb Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Tue, 26 May 2026 16:57:33 +0530 Subject: [PATCH 1/4] updated console sdk signature --- src/Appwrite/Platform/Modules/Presences/HTTP/Update.php | 4 ++-- src/Appwrite/Platform/Modules/Presences/HTTP/Upsert.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Presences/HTTP/Update.php b/src/Appwrite/Platform/Modules/Presences/HTTP/Update.php index 376359717b..37eb7d4659 100644 --- a/src/Appwrite/Platform/Modules/Presences/HTTP/Update.php +++ b/src/Appwrite/Platform/Modules/Presences/HTTP/Update.php @@ -53,7 +53,7 @@ class Update extends PlatformAction name: 'update', desc: 'Update presence', description: '/docs/references/presences/update.md', - auth: [AuthType::SESSION], + auth: [AuthType::SESSION, AuthType::ADMIN], responses: [ new SDKResponse( code: Response::STATUS_CODE_OK, @@ -76,7 +76,7 @@ class Update extends PlatformAction name: 'updatePresence', desc: 'Update presence', description: '/docs/references/presences/update.md', - auth: [AuthType::KEY, AuthType::JWT, AuthType::ADMIN], + auth: [AuthType::KEY, AuthType::JWT], responses: [ new SDKResponse( code: Response::STATUS_CODE_OK, diff --git a/src/Appwrite/Platform/Modules/Presences/HTTP/Upsert.php b/src/Appwrite/Platform/Modules/Presences/HTTP/Upsert.php index be658adbd1..b9d9edfcdd 100644 --- a/src/Appwrite/Platform/Modules/Presences/HTTP/Upsert.php +++ b/src/Appwrite/Platform/Modules/Presences/HTTP/Upsert.php @@ -54,7 +54,7 @@ class Upsert extends PlatformAction name: 'upsert', desc: 'Upsert presence', description: '/docs/references/presences/upsert.md', - auth: [AuthType::SESSION], + auth: [AuthType::SESSION, AuthType::ADMIN], responses: [ new SDKResponse( code: Response::STATUS_CODE_OK, @@ -76,7 +76,7 @@ class Upsert extends PlatformAction name: 'upsert', desc: 'Upsert presence', description: '/docs/references/presences/upsert.md', - auth: [AuthType::KEY, AuthType::JWT, AuthType::ADMIN], + auth: [AuthType::KEY, AuthType::JWT], responses: [ new SDKResponse( code: Response::STATUS_CODE_OK, From d317089d74903265ca7c2b3f9153c13724079bb3 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Tue, 26 May 2026 17:27:27 +0530 Subject: [PATCH 2/4] refactor: improve user ID handling for API key and privileged users in Upsert action --- .../Platform/Modules/Presences/HTTP/Upsert.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Presences/HTTP/Upsert.php b/src/Appwrite/Platform/Modules/Presences/HTTP/Upsert.php index b9d9edfcdd..9b5163fdbf 100644 --- a/src/Appwrite/Platform/Modules/Presences/HTTP/Upsert.php +++ b/src/Appwrite/Platform/Modules/Presences/HTTP/Upsert.php @@ -134,15 +134,13 @@ class Upsert extends PlatformAction throw new Exception(Exception::GENERAL_UNAUTHORIZED_SCOPE, "userId is not allowed for non-API key and non-privileged users"); } - if (($isAPIKey || $isPrivilegedUser) && !$userId) { - throw new Exception(Exception::GENERAL_BAD_REQUEST, "userId is required for API key and privileged users"); + // API keys have no associated session user — they must target one explicitly + if ($isAPIKey && !$userId) { + throw new Exception(Exception::GENERAL_BAD_REQUEST, "userId is required for API key authentication"); } $userInternalId = null; $resolvedUserId = $userId; - if (!$isAPIKey && !$isPrivilegedUser) { - $userInternalId = $user->getSequence(); - $resolvedUserId = $user->getId(); - } else { + if ($userId) { $fetchedUser = $dbForProject->getDocument('users', $userId); if ($fetchedUser->isEmpty()) { throw new Exception(Exception::USER_NOT_FOUND, params: [$userId]); @@ -150,6 +148,9 @@ class Upsert extends PlatformAction $userInternalId = (string) $fetchedUser->getSequence(); $resolvedUserId = $fetchedUser->getId(); + } else { + $userInternalId = $user->getSequence(); + $resolvedUserId = $user->getId(); } if (empty($userInternalId)) { From d5b275992310ee3ee33c5ddc1a66c120452cf6d4 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Wed, 27 May 2026 12:12:20 +0530 Subject: [PATCH 3/4] updated signatures --- src/Appwrite/Platform/Modules/Presences/HTTP/Update.php | 4 ++-- src/Appwrite/Platform/Modules/Presences/HTTP/Upsert.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Presences/HTTP/Update.php b/src/Appwrite/Platform/Modules/Presences/HTTP/Update.php index 37eb7d4659..de76dbff75 100644 --- a/src/Appwrite/Platform/Modules/Presences/HTTP/Update.php +++ b/src/Appwrite/Platform/Modules/Presences/HTTP/Update.php @@ -53,7 +53,7 @@ class Update extends PlatformAction name: 'update', desc: 'Update presence', description: '/docs/references/presences/update.md', - auth: [AuthType::SESSION, AuthType::ADMIN], + auth: [AuthType::SESSION, AuthType::ADMIN, AuthType::JWT], responses: [ new SDKResponse( code: Response::STATUS_CODE_OK, @@ -76,7 +76,7 @@ class Update extends PlatformAction name: 'updatePresence', desc: 'Update presence', description: '/docs/references/presences/update.md', - auth: [AuthType::KEY, AuthType::JWT], + auth: [AuthType::KEY], responses: [ new SDKResponse( code: Response::STATUS_CODE_OK, diff --git a/src/Appwrite/Platform/Modules/Presences/HTTP/Upsert.php b/src/Appwrite/Platform/Modules/Presences/HTTP/Upsert.php index 9b5163fdbf..6f44e77d1a 100644 --- a/src/Appwrite/Platform/Modules/Presences/HTTP/Upsert.php +++ b/src/Appwrite/Platform/Modules/Presences/HTTP/Upsert.php @@ -54,7 +54,7 @@ class Upsert extends PlatformAction name: 'upsert', desc: 'Upsert presence', description: '/docs/references/presences/upsert.md', - auth: [AuthType::SESSION, AuthType::ADMIN], + auth: [AuthType::SESSION, AuthType::ADMIN, AuthType::JWT], responses: [ new SDKResponse( code: Response::STATUS_CODE_OK, @@ -76,7 +76,7 @@ class Upsert extends PlatformAction name: 'upsert', desc: 'Upsert presence', description: '/docs/references/presences/upsert.md', - auth: [AuthType::KEY, AuthType::JWT], + auth: [AuthType::KEY], responses: [ new SDKResponse( code: Response::STATUS_CODE_OK, From 979673bca4522b49e870933171768553c1983b88 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Wed, 27 May 2026 13:36:51 +0530 Subject: [PATCH 4/4] php stan --- src/Appwrite/SDK/Specification/Format/Swagger2.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Appwrite/SDK/Specification/Format/Swagger2.php b/src/Appwrite/SDK/Specification/Format/Swagger2.php index 6d456e1abc..edf6c2823d 100644 --- a/src/Appwrite/SDK/Specification/Format/Swagger2.php +++ b/src/Appwrite/SDK/Specification/Format/Swagger2.php @@ -761,9 +761,7 @@ class Swagger2 extends Format /// If the enum flag is Set, add the enum values to the body $body['schema']['properties'][$name]['enum'] = $node['enum']; $body['schema']['properties'][$name]['x-enum-name'] = $node['x-enum-name'] ?? null; - if (isset($node['x-enum-keys'])) { - $body['schema']['properties'][$name]['x-enum-keys'] = $node['x-enum-keys']; - } + $body['schema']['properties'][$name]['x-enum-keys'] = $node['x-enum-keys']; } if ($parameter['nullable']) {