@@ -323,8 +323,9 @@ const handler = (topic, message, logger, callback) => {
323
323
324
324
// if message has userId such messages will likely need userHandle and user full name
325
325
// so let's get it
326
+ const ids = [ message . initiatorUserId ] ;
326
327
if ( message . userId ) {
327
- const ids = [ message . userId ] ;
328
+ ids . push ( message . userId ) ;
328
329
return service . getUsersById ( ids ) ;
329
330
}
330
331
return [ ] ;
@@ -335,10 +336,15 @@ const handler = (topic, message, logger, callback) => {
335
336
notification . contents . timestamp = ( new Date ( ) ) . toISOString ( ) ;
336
337
// if found a user then add user handle
337
338
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 ;
342
348
}
343
349
} ) ;
344
350
callback ( null , allNotifications ) ;
0 commit comments