mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #2875 from overleaf/cmg-covid-upgrades-script
Create notifications for current WFH 2020 users GitOrigin-RevId: f40ae373815d834cfa4c81bb96a61a799385b8d9
This commit is contained in:
parent
44d706646d
commit
9aa0ca1131
2 changed files with 58 additions and 1 deletions
|
@ -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"
|
||||
)
|
||||
|
|
47
services/web/scripts/wfh_2020_notifications.js
Normal file
47
services/web/scripts/wfh_2020_notifications.js
Normal file
|
@ -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)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
Loading…
Reference in a new issue