Add more achievements to notifications list (#11332)

* Add more achievements to notifications list

* use addNotification

* Fix logic to not award stable achievements over and over

* Improve achievement display

* Fix setting notifications for party inviter

* Add tests that notifications are added correctly

* Fix tests
This commit is contained in:
Phillip Thelen
2019-10-18 17:04:33 +02:00
committed by Matteo Pagliazzi
parent ec7ded042b
commit 360aaa9f0b
8 changed files with 108 additions and 25 deletions

View File

@@ -606,13 +606,25 @@ api.joinGroup = {
promises.push(User.update({
$or: [{'party._id': group._id}, {_id: user._id}],
'achievements.partyUp': {$ne: true},
}, {$set: {'achievements.partyUp': true}}, {multi: true}).exec());
}, {$set: {'achievements.partyUp': true}, $push: {notifications: {type: 'ACHIEVEMENT_PARTY_UP'}}}, {multi: true}).exec());
if (inviter) {
if (inviter.achievements.partyUp !== true) {
// Since the notification list of the inviter is already updated in this save we need to add the notification here
inviter.addNotification('ACHIEVEMENT_PARTY_UP');
}
}
}
if (group.memberCount > 3) {
promises.push(User.update({
$or: [{'party._id': group._id}, {_id: user._id}],
'achievements.partyOn': {$ne: true},
}, {$set: {'achievements.partyOn': true}}, {multi: true}).exec());
}, {$set: {'achievements.partyOn': true}, $push: {notifications: {type: 'ACHIEVEMENT_PARTY_ON'}}}, {multi: true}).exec());
if (inviter) {
if (inviter.achievements.partyOn !== true) {
// Since the notification list of the inviter is already updated in this save we need to add the notification here
inviter.addNotification('ACHIEVEMENT_PARTY_ON');
}
}
}
}