mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
notifications: fixes
This commit is contained in:
@@ -163,10 +163,12 @@ schema.methods.addNotification = function addUserNotification (type, data = {},
|
||||
*/
|
||||
schema.statics.pushNotification = async function pushNotification (query, type, data = {}, seen = false) {
|
||||
let newNotification = new UserNotification({type, data, seen});
|
||||
|
||||
let validationResult = newNotification.validateSync();
|
||||
if (validationResult) {
|
||||
throw validationResult;
|
||||
}
|
||||
|
||||
await this.update(query, {$push: {notifications: newNotification.toObject()}}, {multi: true}).exec();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user