Notification with Service Workers now is working!
When a Notification arrives, it save into the IndexDb, then in Vue.js call a polling to check in the db if there is a different record count. If is different then call a get to update the notification.
This commit is contained in:
@@ -221,9 +221,10 @@ module.exports = {
|
||||
|
||||
const sendemail = require('../sendemail');
|
||||
|
||||
/// ... rivedere il crea gruppo... notifiche...
|
||||
try {
|
||||
if (!recnotif.options) {
|
||||
recnotif.options = shared_consts.MessageOptions.Notify_ByPushNotification + shared_consts.MessageOptions.Notify_ByBotTelegram;
|
||||
if (!recnotif.typesend) {
|
||||
recnotif.typesend = shared_consts.MessageOptions.Notify_ByPushNotification + shared_consts.MessageOptions.Notify_ByBotTelegram;
|
||||
}
|
||||
|
||||
let invia = false;
|
||||
@@ -239,13 +240,16 @@ module.exports = {
|
||||
typenotif,
|
||||
idnotif,
|
||||
usernameDest: recnotif.usernameDest ? recnotif.usernameDest : recnotif.dest,
|
||||
tag: recnotif.tag ? recnotif.tag : '',
|
||||
actions: recnotif.actions ? recnotif.actions : [],
|
||||
id: recnotif._id
|
||||
};
|
||||
|
||||
if (tools.isBitActive(recnotif.options, shared_consts.MessageOptions.Notify_ByPushNotification) && this.checkifSendPushNotification) {
|
||||
if (tools.isBitActive(recnotif.typesend, 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)) {
|
||||
if (tools.isBitActive(recnotif.typesend, shared_consts.MessageOptions.Notify_ByBotTelegram)) {
|
||||
params.typesend = params.typesend + shared_consts.TypeSend.TELEGRAM;
|
||||
invia = true;
|
||||
}
|
||||
@@ -256,7 +260,7 @@ module.exports = {
|
||||
}
|
||||
|
||||
// Send Msg by EMAIL
|
||||
if (tools.isBitActive(recnotif.options, shared_consts.MessageOptions.Notify_ByEmail)) {
|
||||
if (tools.isBitActive(recnotif.typesend, shared_consts.MessageOptions.Notify_ByEmail)) {
|
||||
// Read from the operator table first
|
||||
let emaildest = await Operator.getEmailByUsername(recnotif.dest.idapp, recnotif.dest.username);
|
||||
if (!emaildest)
|
||||
@@ -265,17 +269,17 @@ module.exports = {
|
||||
await sendemail.sendEmail_ByNotif(res, user.lang, emaildest, user, idapp, recnotif);
|
||||
}
|
||||
|
||||
return true;
|
||||
return recnotif;
|
||||
} catch (e) {
|
||||
console.error('sendNotif', e, typenotif, recnotif);
|
||||
return false;
|
||||
return recnotif;
|
||||
}
|
||||
},
|
||||
|
||||
SendMsgToParam: async function(idapp, params) {
|
||||
|
||||
try {
|
||||
console.log('SendMsgToParam');
|
||||
console.log('SendMsgToParam', params.typesend);
|
||||
|
||||
const telegrambot = require('../telegram/telegrambot');
|
||||
|
||||
@@ -356,7 +360,7 @@ module.exports = {
|
||||
if (tools.isBitActive(params.typesend, shared_consts.TypeSend.PUSH_NOTIFICATION)) {
|
||||
const myparam = {...params};
|
||||
risult = tools.sendNotificationToUser(user._id, mytitle, mycontent, myparam.openUrl, myparam.openUrl2, myparam.tag,
|
||||
myparam.actions).
|
||||
myparam.actions, myparam.id).
|
||||
then(ris => {
|
||||
|
||||
}).
|
||||
|
||||
Reference in New Issue
Block a user