From af1635b7da8828baaab17f4030c71fdabbc8539a Mon Sep 17 00:00:00 2001 From: alma Date: Sun, 11 Jan 2026 22:38:57 +0100 Subject: [PATCH] notifications --- lib/services/notifications/rocketchat-adapter.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/services/notifications/rocketchat-adapter.ts b/lib/services/notifications/rocketchat-adapter.ts index 307885c..677ea3e 100644 --- a/lib/services/notifications/rocketchat-adapter.ts +++ b/lib/services/notifications/rocketchat-adapter.ts @@ -45,6 +45,7 @@ export class RocketChatAdapter implements NotificationAdapter { /** * Get RocketChat user ID from email + * Uses the same logic as the messages API: search by username OR email */ private async getRocketChatUserId(email: string): Promise { try { @@ -80,14 +81,19 @@ export class RocketChatAdapter implements NotificationAdapter { logger.debug('[ROCKETCHAT_ADAPTER] Searching for user', { username, + email, totalUsers: usersData.users.length, }); - const currentUser = usersData.users.find((u: any) => u.username === username); + // Use the exact same logic as the messages API + const currentUser = usersData.users.find((user: any) => + user.username === username || user.emails?.some((e: any) => e.address === email) + ); if (!currentUser) { logger.warn('[ROCKETCHAT_ADAPTER] User not found in RocketChat', { username, + email, searchedIn: usersData.users.length, availableUsernames: usersData.users.slice(0, 5).map((u: any) => u.username), }); @@ -96,6 +102,8 @@ export class RocketChatAdapter implements NotificationAdapter { logger.debug('[ROCKETCHAT_ADAPTER] Found user', { username, + email, + rocketChatUsername: currentUser.username, userId: currentUser._id, });