fix: messages and notif Friends Accepteded

This commit is contained in:
Surya Paolo
2022-12-17 22:12:13 +01:00
parent c07e6f214d
commit cfa8569fd9
4 changed files with 41 additions and 18 deletions

View File

@@ -178,10 +178,12 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function(recnotif) {
if (recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_NEW_REC) {
newdescr = i18n.__('<strong>%s</strong> 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)) {
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_ACCEPTED) {
newdescr = i18n.__('<strong>%s</strong> accepted your Friendship', userorig, mydescr);
tag = 'acceptedfriend';
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_ACCEPTED_MY_REQUEST) {
newdescr = i18n.__('✅ You have accepted %s\' Friendship request!', userorig, mydescr);
tag = 'acceptedfriend';
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_REFUSED) {
newdescr = i18n.__('<strong>%s</strong> refused your Friendship', userorig, mydescr);
tag = 'refusedfriend';
@@ -470,12 +472,19 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
let typeidsearch = 0;
let dest = '';
let sender = myrecnotif.sender;
let newdest = myrecnotif.dest;
// Controllare se devo modificare un Notif già esistente !
if (myrecnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_FRIENDS) {
typeidsearch = shared_consts.TypeNotifs.ID_FRIENDS_NEW_REC;
if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_ACCEPTED) {
newstatus = shared_consts.StatusNotifs.STATUS_FRIENDS_ACCEPTED;
dest = myrecnotif.sender;
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_ACCEPTED_MY_REQUEST) {
newstatus = shared_consts.StatusNotifs.STATUS_FRIENDS_ACCEPTED;
newdest = myrecnotif.sender;
sender = myrecnotif.dest;
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_REFUSED) {
newstatus = shared_consts.StatusNotifs.STATUS_FRIENDS_REFUSED;
dest = myrecnotif.sender;
@@ -539,6 +548,8 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
read: false,
descr: myrecnotif.descr,
datenotif: new Date(),
sender,
dest: newdest,
};
let query = {