X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=server%2Fmodels%2FUser.js;h=ff019bdbd873ce4c7989e6ad6fefd0aa31e10ce2;hp=1a5397dbae6d7169e9a183780517843ce4de6ccc;hb=fe4c7e67075416c48aafe9e307bef5afea7937bc;hpb=cf7fac89918e50d8c93f9a09842c9eb53e8841d6 diff --git a/server/models/User.js b/server/models/User.js index 1a5397db..ff019bdb 100644 --- a/server/models/User.js +++ b/server/models/User.js @@ -131,16 +131,19 @@ const UserModel = ///////////////// // NOTIFICATIONS - tryNotify: function(oppId, message) + notify: function(user, message) { - UserModel.getOne("id", oppId, (err,opp) => { - if (!err || !opp.notify) - return; //error is ignored here (TODO: should be logged) - const subject = "vchess.club - notification"; - const body = "Hello " + opp.name + "!\n" + message; - sendEmail(params.mail.noreply, opp.email, subject, body, err => { - res.json(err || {}); - }); + const subject = "vchess.club - notification"; + const body = "Hello " + user.name + "!\n" + message; + sendEmail(params.mail.noreply, user.email, subject, body); + }, + + tryNotify: function(id, message) + { + UserModel.getOne("id", id, (err,user) => { + if (!err || !user.notify) + return; //NOTE: error is ignored here + UserModel.notify(user, message); }); },