2014-02-12 10:23:40 +00:00
|
|
|
Subscription = require('../../models/Subscription').Subscription
|
|
|
|
logger = require("logger-sharelatex")
|
|
|
|
ObjectId = require('mongoose').Types.ObjectId
|
|
|
|
|
|
|
|
module.exports =
|
|
|
|
|
|
|
|
getUsersSubscription: (user_or_id, callback)->
|
|
|
|
if user_or_id? and user_or_id._id?
|
|
|
|
user_id = user_or_id._id
|
|
|
|
else if user_or_id?
|
|
|
|
user_id = user_or_id
|
|
|
|
logger.log user_id:user_id, "getting users subscription"
|
|
|
|
Subscription.findOne admin_id:user_id, callback
|
|
|
|
|
2014-08-07 14:29:06 +00:00
|
|
|
getMemberSubscriptions: (user_id, callback) ->
|
|
|
|
logger.log user_id: user_id, "getting users group subscriptions"
|
|
|
|
Subscription.find(member_ids: user_id).populate("admin_id").exec callback
|