overleaf/services/web/app/coffee/Features/Subscription/UserFeaturesUpdater.coffee
Simon Detheridge 838fe00058 Merge pull request #1531 from sharelatex/spd-notify-users-on-affiliation-upgrade
Notify users when affiliations are upgraded

GitOrigin-RevId: 0f9e92b6a49f2ddef559e9e23fc73436910fb9f6
2019-03-11 11:00:01 +00:00

12 lines
463 B
CoffeeScript

logger = require("logger-sharelatex")
User = require('../../models/User').User
module.exports =
updateFeatures: (user_id, features, callback = (err, features, featuresChanged)->)->
conditions = _id:user_id
update = {}
logger.log user_id:user_id, features:features, "updating users features"
update["features.#{key}"] = value for key, value of features
User.update conditions, update, (err, result)->
callback err, features, result?.nModified == 1