diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-02-02 13:57:49 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-02-02 13:57:49 -0500 |
| commit | 07f648798676d565914dd8e7b1cd78ebfc3b7309 (patch) | |
| tree | db1709d7411c195cf10cfd3798785bb3f0ba9f39 | |
| parent | f3bede603e385049ed777e8d0a91ce1d7a5c5a55 (diff) | |
dont make a million subscriber
| -rw-r--r-- | server/lib/webhook/webhook.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/server/lib/webhook/webhook.js b/server/lib/webhook/webhook.js index 25e3fb8..9e3a4d3 100644 --- a/server/lib/webhook/webhook.js +++ b/server/lib/webhook/webhook.js @@ -60,8 +60,8 @@ var subscribe = module.exports = { var account = data.account[0].account_code[0] var subscrip = data.subscription[0] var uuid = subscrip.uuid[0] - Subscription.findOne({ "uuid": uuid }, function(err, subscription){ - if (err || subscription) return; + Subscription.findOne({ "uuid": uuid }, function(err, old_subscriber){ + // if (err) return; var plan = subscrip.plan[0].plan_code[0].split("-") var plan_type = plan[0] @@ -70,7 +70,7 @@ var subscribe = module.exports = { user.plan_type = plan_type user.plan_level = subscribe.plan_level[plan_type] - var subscriber = new Subscription () + var subscriber = old_subscriber || new Subscription () subscriber.uuid = uuid subscriber.user_id = user._id subscriber.plan_type = plan_type |
