Notifiche - Tutti - non letti
This commit is contained in:
@@ -74,6 +74,8 @@ const tools = require('./general');
|
||||
|
||||
const shared_consts = require('./shared_nodejs');
|
||||
|
||||
const sendemail = require('../sendemail');
|
||||
|
||||
module.exports = {
|
||||
|
||||
getTableByTableName(tablename) {
|
||||
@@ -211,11 +213,55 @@ module.exports = {
|
||||
return mytable;
|
||||
},
|
||||
|
||||
checkifSendPushNotification() {
|
||||
return process.env.ENABLE_PUSHNOTIFICATION === '1';
|
||||
},
|
||||
|
||||
async sendNotif(res, idapp, user, recnotif, cmd) {
|
||||
// Controlla nelle impostazioni che tipo di Notifica visualizzare
|
||||
|
||||
if (tools.isBitActive(recnotif.options, shared_consts.MessageOptions.Notify_ByPushNotification)) {
|
||||
if (this.checkifSendPushNotification) {
|
||||
console.log('SEND PUSH NOTIFICATION ');
|
||||
|
||||
const params = {
|
||||
sendreally: true,
|
||||
typesend: shared_consts.TypeSend.PUSH_NOTIFICATION,
|
||||
title: this.getNomeAppByIdApp(idapp),
|
||||
content: recnotif.descr ? recnotif.descr : tools.getContentByTypeMsg(recnotif.typemsg),
|
||||
openUrl: tools.updateQueryStringParameter(recnotif.link, 'idnotif', recnotif._id),
|
||||
typemsg: recnotif.typemsg ? recnotif.typemsg : shared_consts.TypeMsg.SEND_TO_USER,
|
||||
}
|
||||
|
||||
ris = await this.SendMsgToParam(idapp, params);
|
||||
|
||||
recnotif.link = mylink;
|
||||
}
|
||||
}
|
||||
|
||||
// Send Msg by EMAIL
|
||||
if (emaildest && tools.isBitActive(recnotif.options, shared_consts.MessageOptions.Notify_ByEmail)) {
|
||||
// Read from the operator table first
|
||||
let emaildest = await Operator.getEmailByUsername(recnotif.dest.idapp, recnotif.dest.username);
|
||||
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);
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
SendMsgToParam: async function(idapp, params) {
|
||||
|
||||
try {
|
||||
const telegrambot = require('../telegram/telegrambot');
|
||||
|
||||
if (params.typesend === 0)
|
||||
params.typesend = shared_consts.TypeSend.PUSH_NOTIFICATION;
|
||||
|
||||
let query = {idapp};
|
||||
let addquery = {};
|
||||
|
||||
@@ -249,8 +295,8 @@ module.exports = {
|
||||
addquery = {
|
||||
'profile.teleg_id': {$gt: 1},
|
||||
'profile.username_telegram': {$exists: true},
|
||||
$expr: { $gt: [ { $strLenCP: "$profile.username_telegram" }, 3 ] },
|
||||
'verified_by_aportador': {$exists: false}
|
||||
$expr: {$gt: [{$strLenCP: '$profile.username_telegram'}, 3]},
|
||||
'verified_by_aportador': {$exists: false},
|
||||
};
|
||||
} else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_GROUP) {
|
||||
if (params.groupnameDest) {
|
||||
@@ -287,8 +333,7 @@ module.exports = {
|
||||
let risult = null;
|
||||
|
||||
if (params.sendreally) {
|
||||
if (tools.isBitActive(params.typesend,
|
||||
shared_consts.TypeSend.PUSH_NOTIFICATION)) {
|
||||
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).
|
||||
then(ris => {
|
||||
|
||||
Reference in New Issue
Block a user