Skip to content

Commit 060c33c

Browse files
committed
lint fix
1 parent e481fd2 commit 060c33c

File tree

5 files changed

+40
-39
lines changed

5 files changed

+40
-39
lines changed

connect/connectNotificationServer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ const handler = (topic, message, logger, callback) => {
343343
// first found notification for one user will be send, the rest ignored
344344
// NOTE all userId has to be string
345345
logger.debug('all notifications: ', notificationsPerSource);
346-
return _.uniqBy(_.flatten(notificationsPerSource), 'userId')
346+
return _.uniqBy(_.flatten(notificationsPerSource), 'userId');
347347
}).then((notifications) => (
348348
excludeNotifications(notifications, eventConfig, message, {
349349
project,

connect/events-config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ const EVENTS = [
120120
}, {
121121
type: BUS_API_EVENT.CONNECT.MEMBER.INVITE_APPROVED,
122122
toUserHandle: true,
123-
originator: true
123+
originator: true,
124124
}, {
125125
type: BUS_API_EVENT.CONNECT.MEMBER.INVITE_REJECTED,
126-
originator: true
126+
originator: true,
127127
},
128128

129129
// Project activity

connect/notificationServices/email.js

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,49 +14,48 @@ const {
1414
BUS_API_EVENT,
1515
SCHEDULED_EVENT_PERIOD,
1616
SETTINGS_EMAIL_SERVICE_ID,
17-
ACTIVE_USER_STATUSES
17+
ACTIVE_USER_STATUSES,
1818
} = require('../constants');
1919
const { EVENTS, EVENT_BUNDLES } = require('../events-config');
2020
const helpers = require('../helpers');
2121
const service = require('../service');
2222

2323

24-
function replacePlaceholders(term,data){
24+
function replacePlaceholders(term, data) {
2525
let placeholders = term.match(/<[a-zA-Z]+>/g);
2626
let ret = term;
27-
if (placeholders && placeholders.length){
28-
_(placeholders).each(p=>{
29-
let values = _.map(data,p.slice(1, -1));
27+
if (placeholders && placeholders.length) {
28+
_(placeholders).each(p => {
29+
let values = _.map(data, p.slice(1, -1));
3030
const total = values.length;
31-
let replacement = values.length < 3 ?
32-
values.join(', ') :
33-
values.slice(0,2).join(', ') +' and ' + (total-3) +'others';
31+
let replacement = values.length < 3 ?
32+
values.join(', ') :
33+
values.slice(0, 2).join(', ') + ' and ' + (total - 3) + 'others';
3434
ret = ret.replace(p, values.join(', '));
35-
})
35+
});
3636
}
3737
return ret;
3838
}
3939

40-
function getSections(projectUserEvents){
40+
function getSections(projectUserEvents) {
4141
let sections = [];
4242
_.chain(projectUserEvents)
4343
.groupBy(value => getEventGroupKey(value))
44-
.forIn((value,key)=>{
45-
if (!EVENT_BUNDLES[key].groupBy){
44+
.forIn((value, key) => {
45+
if (!EVENT_BUNDLES[key].groupBy) {
4646
sections.push({
47-
title:replacePlaceholders(EVENT_BUNDLES[key].title,_(value).map(g=>g.data.data).value()),
48-
[key]:true,
49-
notifications: _(value).map(v=>v.data.data).value()
47+
title: replacePlaceholders(EVENT_BUNDLES[key].title, _(value).map(g => g.data.data).value()),
48+
[key]: true,
49+
notifications: _(value).map(v => v.data.data).value(),
5050
});
5151
} else {
52-
_.chain(value).groupBy(n=>n.data.data[EVENT_BUNDLES[key].groupBy]).forIn((groupValue,groupKey)=>{
53-
52+
_.chain(value).groupBy(n => n.data.data[EVENT_BUNDLES[key].groupBy]).forIn((groupValue, groupKey) => {
5453
let title = EVENT_BUNDLES[key].title;
55-
title = replacePlaceholders(title,_(groupValue).map(g=>g.data.data).value());
54+
title = replacePlaceholders(title, _(groupValue).map(g => g.data.data).value());
5655
sections.push({
5756
title,
58-
[key]:true,
59-
notifications: _(groupValue).map(g=>g.data.data).value()
57+
[key]: true,
58+
notifications: _(groupValue).map(g => g.data.data).value(),
6059
});
6160
}).value();
6261
}
@@ -92,7 +91,7 @@ function handleScheduledEvents(events, setEventsStatus) {
9291
.mapValues(projectUserEvents => ({
9392
id: _.get(projectUserEvents, '[0].data.data.projectId'),
9493
name: _.get(projectUserEvents, '[0].data.data.projectName'),
95-
sections: getSections(projectUserEvents)
94+
sections: getSections(projectUserEvents),
9695
}))
9796
.values()
9897
.value(),
@@ -104,7 +103,7 @@ function handleScheduledEvents(events, setEventsStatus) {
104103

105104
// update common values for bundled email
106105
eventMessage.replyTo = config.DEFAULT_REPLY_EMAIL;
107-
eventMessage.version="v3";
106+
eventMessage.version = 'v3';
108107
eventMessage.cc = [];
109108
eventMessage.from = {
110109
name: config.REPLY_EMAIL_FROM,
@@ -145,8 +144,8 @@ function getEventGroupKey(value) {
145144
.keys()
146145
.find(key => _.includes(_.get(EVENT_BUNDLES, `${key}.types`), _.get(value, 'data.data.type')))
147146
.value();
148-
if (!key) return 'DEFAULT';
149-
return key;
147+
if (!key) return 'DEFAULT';
148+
return key;
150149
}
151150

152151
/**
@@ -157,7 +156,7 @@ function getEventGroupKey(value) {
157156
*/
158157
function wrapIndividualNotification(data) {
159158
const key = getEventGroupKey(data);
160-
const subject = replacePlaceholders(EVENT_BUNDLES[key].subject,[data.data.data]);
159+
const subject = replacePlaceholders(EVENT_BUNDLES[key].subject, [data.data.data]);
161160

162161
return {
163162
subject,
@@ -212,7 +211,7 @@ function handler(topicName, messageJSON, notification) {
212211
// don't send email notification for inactive users, ideally we should not have generated
213212
// notifications for inactive users, however, for now handling it here as safe gaurd
214213
if (userStatus && ACTIVE_USER_STATUSES.indexOf(userStatus) === -1) {
215-
logger.error(`Notification generated for inactive user, ignoring`);
214+
logger.error('Notification generated for inactive user, ignoring');
216215
return;
217216
}
218217
if (config.ENABLE_DEV_MODE === 'true') {
@@ -236,16 +235,16 @@ function handler(topicName, messageJSON, notification) {
236235
emailToAffectedUser: notification.contents.userEmail === userEmail,
237236
},
238237
recipients,
239-
version:"v3",
238+
version: 'v3',
240239
from: {
241240
name: notification.contents.userHandle,
242241
email: config.DEFAULT_REPLY_EMAIL,
243242
},
244243
categories,
245244
};
246-
eventMessage.data[eventMessage.data.type]=true;
247-
_.assign(eventMessage.data,notification.contents);
248-
245+
eventMessage.data[eventMessage.data.type] = true;
246+
_.assign(eventMessage.data, notification.contents);
247+
249248

250249
// default values that get overridden when the notification is about topics/posts updates
251250
let reference = 'project';
@@ -256,7 +255,7 @@ function handler(topicName, messageJSON, notification) {
256255
messagingEvent = true;
257256
eventMessage.data.topicId = parseInt(messageJSON.topicId, 10);
258257
eventMessage.data.postId = messageJSON.postId ? parseInt(messageJSON.postId, 10) : null;
259-
if (messageJSON.postContent){
258+
if (messageJSON.postContent) {
260259
eventMessage.data.post = helpers.markdownToHTML(messageJSON.postContent);
261260
}
262261

@@ -304,9 +303,9 @@ function handler(topicName, messageJSON, notification) {
304303
// if we find the event category for the notification, use the bundle settings from the first event
305304
if (eventBundle && eventBundle.types && eventBundle.types.length) {
306305
const firstEvtInBundle = eventBundle.types[0];
307-
const firstEvtBundleSettingPath = `notifications['${firstEvtInBundle}'].${SETTINGS_EMAIL_SERVICE_ID}.bundlePeriod`
306+
const firstEvtBundleSettingPath = `notifications['${firstEvtInBundle}'].${SETTINGS_EMAIL_SERVICE_ID}.bundlePeriod`;
308307
let firstEvtBundlePeriod = _.get(settings, firstEvtBundleSettingPath);
309-
bundlePeriod = firstEvtBundlePeriod
308+
bundlePeriod = firstEvtBundlePeriod;
310309
logger.debug('Assuming bundle period of first event in the event category=>', bundlePeriod);
311310
}
312311
}
@@ -315,7 +314,7 @@ function handler(topicName, messageJSON, notification) {
315314
}
316315
logger.debug('bundlePeriod=>', bundlePeriod);
317316

318-
if (bundlePeriod && "immediately" !== bundlePeriod && !requiresImmediateAttention) {
317+
if (bundlePeriod && 'immediately' !== bundlePeriod && !requiresImmediateAttention) {
319318
if (!SCHEDULED_EVENT_PERIOD[bundlePeriod]) {
320319
throw new Error(`User's '${notification.userId}' setting for service`
321320
+ ` '${SETTINGS_EMAIL_SERVICE_ID}' option 'bundlePeriod' has unsupported value '${bundlePeriod}'.`);
@@ -332,7 +331,7 @@ function handler(topicName, messageJSON, notification) {
332331
});
333332
} else {
334333
// send single field "notificationsHTML" with the rendered template
335-
eventMessage.data = wrapIndividualNotification({data:eventMessage});
334+
eventMessage.data = wrapIndividualNotification({ data: eventMessage });
336335
console.log(eventMessage.data.contents);
337336

338337
// send event to bus api

src/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function startKafkaConsumer(handlers, notificationServiceHandlers) {
7474
});
7575
});
7676

77-
77+
7878
consumer
7979
.init()
8080
.then(() => _.each(_.keys(handlers),

src/services/NotificationService.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ function* listNotifications(query, userId) {
185185
if (_.keys(notificationSettings).length > 0) {
186186
// only filter out notifications types which were explicitly set to 'no' - so we return notification by default
187187
const notifications = _.keys(notificationSettings).filter((notificationType) =>
188+
!notificationSettings[notificationType] ||
189+
!notificationSettings[notificationType].web ||
188190
notificationSettings[notificationType].web.enabled !== 'no'
189191
);
190192
filter.where.type = { $in: notifications };

0 commit comments

Comments
 (0)