From c6475e7ea7763987fbc9d2a194d91e9cd8b4e33f Mon Sep 17 00:00:00 2001 From: spencrmartin Date: Mon, 17 Nov 2025 16:29:35 -0500 Subject: [PATCH] fix: Matrix invitation user ID formatting Fixed MatrixError: Expected UserID string to start with '@' The issue was that Matrix user IDs must always start with '@' but the inviteToRoom method was not ensuring proper formatting. Changes: - Added user ID formatting in MatrixService.inviteToRoom() - Ensures userId starts with '@' before sending to Matrix client - Added logging to show original vs formatted user ID - Handles cases where user IDs come without '@' prefix This fixes invitation failures when user IDs don't have proper Matrix format. --- ui/desktop/src/services/MatrixService.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ui/desktop/src/services/MatrixService.ts b/ui/desktop/src/services/MatrixService.ts index af97cc6245..5885fc20d5 100644 --- a/ui/desktop/src/services/MatrixService.ts +++ b/ui/desktop/src/services/MatrixService.ts @@ -870,7 +870,17 @@ export class MatrixService extends EventEmitter { throw new Error('Client not initialized'); } - await this.client.invite(roomId, userId); + // Ensure userId starts with '@' as required by Matrix + const formattedUserId = userId.startsWith('@') ? userId : `@${userId}`; + + console.log('🔗 Inviting user to room:', { + roomId, + originalUserId: userId, + formattedUserId, + needsFormatting: !userId.startsWith('@') + }); + + await this.client.invite(roomId, formattedUserId); } /**