From 02d5ad35c6dd1d6aaa2217c9706982cdb8d72e24 Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Fri, 18 Oct 2019 21:01:40 +0200 Subject: [PATCH] fix notification --- website/server/controllers/api-v3/groups.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/website/server/controllers/api-v3/groups.js b/website/server/controllers/api-v3/groups.js index 50394127c3..30f60754a5 100644 --- a/website/server/controllers/api-v3/groups.js +++ b/website/server/controllers/api-v3/groups.js @@ -26,6 +26,7 @@ import payments from '../../libs/payments/payments'; import stripePayments from '../../libs/payments/stripe'; import amzLib from '../../libs/payments/amazon'; import apiError from '../../libs/apiError'; +import { model as UserNotification } from '../../models/userNotification'; const MAX_EMAIL_INVITES_BY_USER = 200; const TECH_ASSISTANCE_EMAIL = nconf.get('EMAILS_TECH_ASSISTANCE_EMAIL'); @@ -630,6 +631,8 @@ api.joinGroup = { if (group.type === 'party' && inviter) { if (group.memberCount > 1) { + const notif = new UserNotification({ type: 'ACHIEVEMENT_PARTY_UP' }); + promises.push(User.update( { $or: [{ 'party._id': group._id }, { _id: user._id }], @@ -637,7 +640,7 @@ api.joinGroup = { }, { $set: { 'achievements.partyUp': true }, - $push: { notifications: { type: 'ACHIEVEMENT_PARTY_UP' } }, + $push: { notifications: notif }, }, { multi: true }, ).exec()); @@ -652,6 +655,8 @@ api.joinGroup = { } if (group.memberCount > 3) { + const notif = new UserNotification({ type: 'ACHIEVEMENT_PARTY_ON' }); + promises.push(User.update( { $or: [{ 'party._id': group._id }, { _id: user._id }], @@ -659,7 +664,7 @@ api.joinGroup = { }, { $set: { 'achievements.partyOn': true }, - $push: { notifications: { type: 'ACHIEVEMENT_PARTY_ON' } }, + $push: { notifications: notif }, }, { multi: true }, ).exec());