@@ -86,27 +86,25 @@ const getNotificationsForMentionedUser = (logger, eventConfig, content) => {
8686 // only one per userHandle
8787 notifications = _ . uniqBy ( notifications , 'userHandle' ) ;
8888
89- return new Promise ( ( resolve , reject ) => { // eslint-disable-line no-unused-vars
90- const handles = _ . map ( notifications , 'userHandle' ) ;
91- if ( handles . length > 0 ) {
92- return service . getUsersByHandle ( handles ) . then ( ( users ) => {
93- _ . forEach ( notifications , ( notification ) => {
94- const mentionedUser = _ . find ( users , { handle : notification . userHandle } ) ;
95- notification . userId = mentionedUser ? mentionedUser . userId . toString ( ) : notification . userHandle ;
96- } ) ;
97- resolve ( notifications ) ;
98- } ) /*.catch((error) => {
99- if (logger) {
100- logger.error(error);
101- logger.info('Unable to send notification to mentioned user')
102- }
103- //resolves with empty notification which essentially means we are unable to send notification to mentioned user
104- resolve([]);
105- })*/ ;
106- } else {
107- resolve ( [ ] ) ;
108- }
109- } ) ;
89+ const handles = _ . map ( notifications , 'userHandle' ) ;
90+ if ( handles . length > 0 ) {
91+ return service . getUsersByHandle ( handles ) . then ( ( users ) => {
92+ _ . forEach ( notifications , ( notification ) => {
93+ const mentionedUser = _ . find ( users , { handle : notification . userHandle } ) ;
94+ notification . userId = mentionedUser ? mentionedUser . userId . toString ( ) : notification . userHandle ;
95+ } ) ;
96+ return Promise . resolve ( notifications ) ;
97+ } ) . catch ( ( error ) => {
98+ if ( logger ) {
99+ logger . error ( error ) ;
100+ logger . info ( 'Unable to send notification to mentioned user' )
101+ }
102+ //resolves with empty notification which essentially means we are unable to send notification to mentioned user
103+ return Promise . resolve ( [ ] ) ;
104+ } ) ;
105+ } else {
106+ return Promise . resolve ( [ ] ) ;
107+ }
110108} ;
111109
112110/**
0 commit comments