From 20162a69be3dd6bd0436d08c37f418f88916a48a Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Wed, 13 May 2026 14:26:23 +0530 Subject: [PATCH] feat: ensure unique ID assignment for new presence documents --- src/Appwrite/Databases/PresenceState.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Databases/PresenceState.php b/src/Appwrite/Databases/PresenceState.php index 0dab0bed63..63c69afd52 100644 --- a/src/Appwrite/Databases/PresenceState.php +++ b/src/Appwrite/Databases/PresenceState.php @@ -10,6 +10,7 @@ use Utopia\Database\Exception\Conflict as ConflictException; use Utopia\Database\Exception\Duplicate as DuplicateException; use Utopia\Database\Exception\NotFound as NotFoundException; use Utopia\Database\Exception\Structure as StructureException; +use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; use Utopia\Database\Query; @@ -61,9 +62,10 @@ class PresenceState mixed $userInternalId, ?callable $onPresenceCreated = null ): Document { - if ($presenceId !== 'unique()') { - $presenceDocument->setAttribute('$id', $presenceId); + if ($presenceId === 'unique()') { + $presenceId = ID::unique(); } + $presenceDocument->setAttribute('$id', $presenceId); $presenceCreated = false;