Skip to content

Commit 66329d4

Browse files
author
Vikas Agarwal
committed
Trying to get more information of initiator user
1 parent a3b035b commit 66329d4

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

connect/connectNotificationServer.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,9 @@ const handler = (topic, message, logger, callback) => {
323323

324324
// if message has userId such messages will likely need userHandle and user full name
325325
// so let's get it
326+
const ids = [message.initiatorUserId];
326327
if (message.userId) {
327-
const ids = [message.userId];
328+
ids.push(message.userId);
328329
return service.getUsersById(ids);
329330
}
330331
return [];
@@ -335,10 +336,15 @@ const handler = (topic, message, logger, callback) => {
335336
notification.contents.timestamp = (new Date()).toISOString();
336337
// if found a user then add user handle
337338
if (users.length) {
338-
notification.contents.userHandle = users[0].handle;
339-
notification.contents.userFullName = `${users[0].firstName} ${users[0].lastName}`;
340-
notification.contents.userEmail = users[0].email;
341-
notification.contents.photoURL = users[0].photoURL;
339+
const affectedUser = _.find(users, u => u.userId === message.userId);
340+
const initiatorUser = _.find(users, u => u.userId === message.initiatorUserId);
341+
if (affectedUser) {
342+
notification.contents.userHandle = affectedUser.handle;
343+
notification.contents.userFullName = `${affectedUser.firstName} ${affectedUser.lastName}`;
344+
notification.contents.userEmail = affectedUser.email;
345+
notification.contents.photoURL = affectedUser.photoURL;
346+
}
347+
notification.contents.initiatorUser = initiatorUser;
342348
}
343349
});
344350
callback(null, allNotifications);

0 commit comments

Comments
 (0)