diff --git a/src/server/models/sendmsg.js b/src/server/models/sendmsg.js
index 11c0233..a0c2d3f 100755
--- a/src/server/models/sendmsg.js
+++ b/src/server/models/sendmsg.js
@@ -35,7 +35,7 @@ const sendmsgSchema = new Schema({
status: {
type: Number,
},
- options: {
+ typesend: {
type: Number,
},
read: {
diff --git a/src/server/models/sendnotif.js b/src/server/models/sendnotif.js
index ce18644..9437a6f 100755
--- a/src/server/models/sendnotif.js
+++ b/src/server/models/sendnotif.js
@@ -55,7 +55,7 @@ const sendNotifSchema = new Schema({
type: Number,
default: 0,
},
- options: {
+ typesend: {
type: Number,
},
read: {
@@ -75,6 +75,12 @@ const sendNotifSchema = new Schema({
extrafield: {
type: String,
},
+ tag: {
+ type: String,
+ },
+ options: {
+ type: Array,
+ },
});
@@ -144,20 +150,26 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
if (recnotif.typeid === shared_consts.TypeNotifs.ID_BACHECA_NEW_GOOD) {
newdescr = i18n.__('%s new Good: %s', userorig, mydescr);
recnotif.openUrl = '/mygood/' + myidrec;
+ tag = 'newgood';
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_BACHECA_NEW_SERVICE) {
newdescr = i18n.__('%s new Service: %s', userorig, mydescr);
recnotif.openUrl = '/myservice/' + myidrec;
+ tag = 'newservice';
}
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_FRIENDS) {
recnotif.openUrl = '/my/' + userorig;
if (recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_NEW_REC) {
newdescr = i18n.__('%s asked you for Friendship', userorig, mydescr);
+ tag = 'newfriend';
} else if ((recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_ACCEPTED) ||
(recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_ACCEPTED_MY_REQUEST)) {
newdescr = i18n.__('%s accepted your Friendship', userorig, mydescr);
+ tag = 'acceptedfriend';
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_REFUSED) {
newdescr = i18n.__('%s refused your Friendship', userorig, mydescr);
+ tag = 'refusedfriend';
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_REPORTED) {
+ tag = 'reportuser';
if (recnotif.paramsObj.usernameDest === recnotif.paramsObj.username_action) {
newdescr = i18n.__('FRIEND_REPORTED_YOU', recnotif.paramsObj.username_worked);
} else if (recnotif.paramsObj.isAdmin) {
@@ -167,6 +179,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
}
}
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
+ tag = 'group';
recnotif.openUrl = '/grp/' + recnotif.paramsObj.groupnameDest;
if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_NEW_REC) {
newdescr = i18n.__('GROUP_CREATED', userorig, recnotif.paramsObj.groupnameDest);
@@ -202,7 +215,6 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
newdescr = i18n.__('GRUPPO_ELIMINATO', userorig, recnotif.paramsObj.username_action);
tag = 'deletegroup';
}
-
}
recnotif.tag = recnotif.tag ? recnotif.tag : tag;
@@ -274,26 +286,25 @@ sendNotifSchema.statics.saveAndSendNotif = async function(myrecnotif, req, res,
if (!myrecout)
return null;
- if (save) {
- await myrecout.save().then((writeresult) => {
- let idobj = writeresult._id;
+ // console.log('myrecout._id', myrecout._id.toString());
- return SendNotif.findById(idobj).lean().then(async (recnotif) => {
- return await globalTables.sendNotif(myrecnotif.typedir, myrecnotif.typeid, res, idapp, user ? user : req.user, recnotif).
- then((ris) => {
- return recnotif;
- });
- });
+ if (save) {
+ await myrecout.save().then(async (res) => {
+ if (res) {
+ const idobj = res._id;
+
+ const myrecread = await SendNotif.findById(idobj).lean();
+ // console.log('myrecread._id', myrecread._id.toString());
+
+ return await globalTables.sendNotif(myrecread.typedir, myrecread.typeid, res, idapp, user ? user : req.user, myrecread);
+ }
}).catch((e) => {
console.log(e.message);
return null;
});
} else {
- return await globalTables.sendNotif(myrecout.typedir, myrecout.typeid, res, idapp, user ? user : req.user, myrecout).
- then((ris) => {
- return myrecout;
- });
+ return await globalTables.sendNotif(myrecout.typedir, myrecout.typeid, res, idapp, user ? user : req.user, myrecout);
}
};
@@ -373,7 +384,7 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
}
}
- myrecnotif._id = new ObjectID();
+ // myrecnotif._id = new ObjectID();
if (newstatus > 0) {
myrecnotif.status = newstatus;
}
@@ -431,7 +442,8 @@ sendNotifSchema.statics.getExtraParam = function(myrecnotif, paramsObj) {
//out = myrecnotif._doc
//}
out.paramsObj = paramsObj;
- out.options = paramsObj.options ? paramsObj.options : 0;
+ out.options = paramsObj.options ? paramsObj.options : [];
+ out.typesend = paramsObj.typesend ? paramsObj.typesend : 0;
out.extrafield = paramsObj.groupnameDest ? paramsObj.groupnameDest : '';
return myrecnotif;
diff --git a/src/server/router/push_router.js b/src/server/router/push_router.js
index b950e18..83f21d5 100755
--- a/src/server/router/push_router.js
+++ b/src/server/router/push_router.js
@@ -93,7 +93,7 @@ async function SendMsgTo(idapp, username, params) {
if (arrusers !== null) {
for (const user of arrusers) {
tools.sendNotificationToUser(user._id, params.title, params.content,
- params.openUrl, params.openUrl2, params.tag, params.actions).
+ params.openUrl, params.openUrl2, params.tag, params.actions, params.id).
then(ris => {
if (ris) {
diff --git a/src/server/router/sendmsg_router.js b/src/server/router/sendmsg_router.js
index e331e87..313051e 100755
--- a/src/server/router/sendmsg_router.js
+++ b/src/server/router/sendmsg_router.js
@@ -50,7 +50,7 @@ router.post('/', authenticate, (req, res) => {
recmsg.typedir = shared_consts.TypeNotifs.TYPEDIR_EVENTS;
recmsg.typeid = shared_consts.TypeNotifs.ID_EVENTS_REMOVE_REC;
- return SendNotif.saveAndSendNotif(recmyevent, req, res).then((out) => {
+ return await SendNotif.saveAndSendNotif(recmyevent, req, res).then((out) => {
if (out)
return res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: recmsg._id });
else
diff --git a/src/server/telegram/telegrambot.js b/src/server/telegram/telegrambot.js
index 83c1ff9..addee3e 100755
--- a/src/server/telegram/telegrambot.js
+++ b/src/server/telegram/telegrambot.js
@@ -3408,7 +3408,7 @@ class Telegram {
}
try {
- console.log('<<< SEND MSG: >>> ', text.substring(0, 100));
+ console.log('<<< SEND MSG TELEGRAM: >>> ', text.substring(0, 100));
text = text.replace(/
/g, '\n');
text = text.replace(/
/g, '\n');
text = text.replace(/