diff --git a/services/web/app/views/project/list/notifications.pug b/services/web/app/views/project/list/notifications.pug index 85979d79c4..0153ca8964 100644 --- a/services/web/app/views/project/list/notifications.pug +++ b/services/web/app/views/project/list/notifications.pug @@ -36,7 +36,17 @@ include ../../_mixins/saml button(ng-click="dismiss(notification)").close.pull-right span(aria-hidden="true") × span.sr-only #{translate("close")} - + .alert.alert-info( + ng-switch-when="wfh_2020_upgrade_offer" + ) + .notification-body + span Good news! Your WFH2020 free upgrade is extended to June 30th 2020. We're also providing specially discounted annual plans to help you continue collaborating throughout 2020. + .notification-action + a.pull-right.btn.btn-sm.btn-info(href="https://www.overleaf.com/events/wfh2020") See options + .notification-close + button(ng-click="dismiss(notification)").close.pull-right + span(aria-hidden="true") × + span.sr-only #{translate("close")} .alert.alert-info( ng-switch-when="notification_ip_matched_affiliation" ) diff --git a/services/web/scripts/wfh_2020_notifications.js b/services/web/scripts/wfh_2020_notifications.js new file mode 100644 index 0000000000..dfd846f614 --- /dev/null +++ b/services/web/scripts/wfh_2020_notifications.js @@ -0,0 +1,47 @@ +const NotificationsHandler = require('../app/src/Features/Notifications/NotificationsHandler') + +const mongojs = require('../app/src/infrastructure/mongojs') +const { db } = mongojs +const async = require('async') + +const templateKey = 'wfh_2020_upgrade_offer' +const key = 'wfh-2020-upgrade-2020-06-01' + +db.subscriptions.aggregate( + { $match: { teamName: /(Work From Home|Work from Home)/ } }, + { $unwind: '$member_ids' }, + { $group: { _id: null, memberIds: { $addToSet: '$member_ids' } } }, + function(err, results) { + if (err) { + throw err + } + + const userIds = results[0].memberIds + + async.eachLimit( + userIds, + 10, + function(userId, callback) { + NotificationsHandler.createNotification( + userId, + key, + templateKey, + {}, + null, + true, + function(err) { + if (err) { + return callback(err) + } + console.log('Notification created for user ' + userId) + callback() + } + ) + }, + function() { + console.log('Done') + process.exit(0) + } + ) + } +)