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.
This commit is contained in:
spencrmartin
2025-11-17 16:29:35 -05:00
parent e6656b9288
commit c6475e7ea7
+11 -1
View File
@@ -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);
}
/**