Merge pull request #12397 from appwrite/console-presence-signature-change

Update presence methods to clarify SDK authentication requirements
This commit is contained in:
Jake Barnby authored and GitHub committed 2026-05-27 21:29:28 +12:00
commit a20e814188
3 files changed
+12 -13

No files matched your search

@@ -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,
@@ -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)) {
@@ -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']) {