Notification: Set a new Friendship and Accepted Friendship

This commit is contained in:
Paolo Arena
2022-07-26 15:46:39 +02:00
parent b06f1e4ab8
commit 3515914f17
15 changed files with 411 additions and 150 deletions

View File

@@ -223,27 +223,36 @@ module.exports = {
try {
if (!recnotif.options) {
recnotif.options = shared_consts.MessageOptions.Notify_ByPushNotification;
recnotif.options = shared_consts.MessageOptions.Notify_ByPushNotification + shared_consts.MessageOptions.Notify_ByBotTelegram;
}
if (tools.isBitActive(recnotif.options, shared_consts.MessageOptions.Notify_ByPushNotification)) {
if (this.checkifSendPushNotification) {
let invia = false;
const params = {
sendreally: true,
typesend: shared_consts.TypeSend.PUSH_NOTIFICATION + shared_consts.TypeSend.TELEGRAM,
title: tools.getNomeAppByIdApp(idapp),
content: recnotif.descr ? recnotif.descr : tools.getContentByTypeMsg(recnotif.typemsg),
openUrl: tools.updateQueryStringParameter(recnotif.openUrl, 'idnotif', recnotif._id),
typemsg: recnotif.typemsg ? recnotif.typemsg : shared_consts.TypeMsg.SEND_TO_USER,
typenotif,
idnotif,
usernameDest: recnotif.usernameDest ? recnotif.usernameDest : recnotif.dest,
};
let params = {
idapp,
sendreally: true,
typesend: 0,
title: tools.getNomeAppByIdApp(idapp),
content: recnotif.descr ? recnotif.descr : tools.getContentByTypeMsg(recnotif.typemsg),
openUrl: tools.updateQueryStringParameter(recnotif.openUrl, 'idnotif', recnotif._id),
typemsg: recnotif.typemsg ? recnotif.typemsg : shared_consts.TypeMsg.SEND_TO_USER,
typenotif,
idnotif,
usernameDest: recnotif.usernameDest ? recnotif.usernameDest : recnotif.dest,
};
ris = await this.SendMsgToParam(idapp, params);
if (tools.isBitActive(recnotif.options, shared_consts.MessageOptions.Notify_ByPushNotification) && this.checkifSendPushNotification) {
params.typesend = params.typesend + shared_consts.TypeSend.PUSH_NOTIFICATION;
invia = true;
}
if (tools.isBitActive(recnotif.options, shared_consts.MessageOptions.Notify_ByBotTelegram)) {
params.typesend = params.typesend + shared_consts.TypeSend.TELEGRAM;
invia = true;
}
}
if (invia) {
ris = await this.SendMsgToParam(idapp, params);
}
// Send Msg by EMAIL
@@ -253,9 +262,7 @@ module.exports = {
if (!emaildest)
emaildest = await User.getEmailByUsername(recnotif.dest.idapp, recnotif.dest.username);
console.log('emaildest', emaildest);
await sendemail.sendEmail_Msg(res, user.lang, emaildest, user, idapp, recnotif);
await sendemail.sendEmail_ByNotif(res, user.lang, emaildest, user, idapp, recnotif);
}
return true;
@@ -347,8 +354,9 @@ module.exports = {
if (params.sendreally) {
if (tools.isBitActive(params.typesend, shared_consts.TypeSend.PUSH_NOTIFICATION)) {
risult = tools.sendNotificationToUser(user._id, mytitle, mycontent, params.openUrl, params.openUrl2, params.tag,
params.actions).
const myparam = {...params};
risult = tools.sendNotificationToUser(user._id, mytitle, mycontent, myparam.openUrl, myparam.openUrl2, myparam.tag,
myparam.actions).
then(ris => {
}).
@@ -361,8 +369,8 @@ module.exports = {
const telegid = user.profile.teleg_id;
if (telegid > 0) {
risult = await telegrambot.local_sendMsgTelegramByIdTelegram(idapp, telegid, mycontent);
await tools.snooze(100);
risult = await telegrambot.local_sendMsgTelegramByIdTelegram(idapp, telegid, tools.getContentNotifByParams(params, mycontent, shared_consts.TypeSend.TELEGRAM));
await tools.snooze(50);
}
}
}