Skip to content

Commit 2995d5a

Browse files
author
Vikas Agarwal
committed
Using first event in the category of the notification type in case we don’t find a setting for the notification type. This mostly happens for a new notification type.
1 parent 4a666ef commit 2995d5a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

connect/notificationServices/email.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,19 @@ function handler(topicName, messageJSON, notification) {
292292
bundlePeriod = bundlePeriod && bundlePeriod.trim().length > 0 ? bundlePeriod : null;
293293
// if bundling is not explicitly set and the event is not a messaging event, assume bundling enabled
294294
if (!bundlePeriod && !messagingEvent) {
295+
// finds the event category for the notification type
296+
let eventBundleCategory = _.findKey(EVENT_BUNDLES, b => b.types && b.types.indexOf(notificationType) !== -1);
297+
if (eventBundleCategory) {
298+
const eventBundle = EVENT_BUNDLES[eventBundleCategory];
299+
// if we find the event category for the notification, use the bundle settings from the first event
300+
if (eventBundle && eventBundle.types && eventBundle.types.length) {
301+
const firstEvtInBundle = eventBundle.types[0];
302+
const firstEvtBundleSettingPath = `notifications['${firstEvtInBundle}'].${SETTINGS_EMAIL_SERVICE_ID}.bundlePeriod`
303+
let firstEvtBundlePeriod = _.get(settings, firstEvtBundleSettingPath);
304+
bundlePeriod = firstEvtBundlePeriod
305+
logger.debug('Assuming bundle period of first event in the event category=>', bundlePeriod);
306+
}
307+
}
295308
// if bundle period is not set, assume it to be daily for default case
296309
bundlePeriod = !bundlePeriod ? 'daily' : bundlePeriod;
297310
}

0 commit comments

Comments
 (0)