diff --git a/src/Appwrite/Platform/Modules/Presences/HTTP/Update.php b/src/Appwrite/Platform/Modules/Presences/HTTP/Update.php index 376359717b..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], + 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, AuthType::ADMIN], + 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 be658adbd1..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], + 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, AuthType::ADMIN], + auth: [AuthType::KEY], responses: [ new SDKResponse( code: Response::STATUS_CODE_OK, @@ -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)) { 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']) {