feat: ensure unique ID assignment for new presence documents

This commit is contained in:
ArnabChatterjee20k committed 2026-05-13 14:26:23 +05:30
1 parent f1e0ef2991
commit 20162a69be
1 file changed
+4 -2
+4 -2
View File
@@ -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;