X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=server%2Fmodels%2FUser.js;h=70d8b52151ab306fad3713fc5ad3786d8b884c6e;hb=a749972cf93fd021dda11389753ae4985ff61b42;hp=1a5397dbae6d7169e9a183780517843ce4de6ccc;hpb=dac395887d96e2d642b209c6db6aaacc3ffacb34;p=vchess.git diff --git a/server/models/User.js b/server/models/User.js index 1a5397db..70d8b521 100644 --- a/server/models/User.js +++ b/server/models/User.js @@ -131,16 +131,20 @@ 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 + "!" + ` +` + 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); }); },