mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Add script that refreshes all v1 users' features in v2
This commit is contained in:
parent
f7b19d9183
commit
89d5605874
1 changed files with 37 additions and 0 deletions
37
services/web/scripts/sync_v1_subscriptions.js
Normal file
37
services/web/scripts/sync_v1_subscriptions.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
const {db} = require('../app/js/infrastructure/mongojs')
|
||||
const FeaturesUpdater = require(
|
||||
'../app/js/Features/Subscription/FeaturesUpdater'
|
||||
)
|
||||
const V1SubscriptionManager = require(
|
||||
'../app/js/Features/Subscription/V1SubscriptionManager'
|
||||
)
|
||||
const async = require('async')
|
||||
const logger = require('logger-sharelatex')
|
||||
logger.logger.level('error')
|
||||
|
||||
db.users.find({
|
||||
'overleaf.id': { $exists: true }
|
||||
}, {
|
||||
overleaf: 1
|
||||
}, function (error, users) {
|
||||
if (error) throw error
|
||||
console.log('Found users:', users.length)
|
||||
async.mapSeries(users, function (user, callback) {
|
||||
console.log('refreshing in v2', user._id)
|
||||
FeaturesUpdater.refreshFeatures(user._id, false, function (error) {
|
||||
if (error) console.error('ERROR', error)
|
||||
console.log('refreshing in v1', user._id)
|
||||
V1SubscriptionManager.notifyV1OfFeaturesChange(
|
||||
user._id,
|
||||
function (error) {
|
||||
if (error) console.error('ERROR', error)
|
||||
callback()
|
||||
}
|
||||
)
|
||||
})
|
||||
}, function (error) {
|
||||
if (error) throw error
|
||||
console.log('FINISHED!')
|
||||
process.exit()
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue