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

@@ -44,9 +44,7 @@ router.post('/', authenticate, (req, res) => {
}).then(async (recmyevent) => {
// tools.mylog('myevent:', myevent);
// tools.mylog('already exist');
recmyevent.typedir = shared_consts.TypeNotifs.TYPEDIR_EVENTS
recmyevent.typeid = shared_consts.TypeNotifs.ID_EVENTS_NEW_REC
await SendNotif.saveAndSendNotif(recmyevent, req, res);
SendNotif.createNewNotification(req, res, shared_consts.TABLES_MYEVENTS, recmyevent, shared_consts.TypeNotifs.TYPEDIR_EVENTS, shared_consts.TypeNotifs.ID_EVENTS_NEW_REC);
return res;
}).then((res) => {
res.send({code: server_constants.RIS_CODE_OK, msg: '', id: recmyevent._id});
@@ -61,9 +59,8 @@ router.post('/', authenticate, (req, res) => {
myevent.findById(idobj).then((recmyevent) => {
recmyevent.typedir = shared_consts.TypeNotifs.TYPEDIR_EVENTS
recmyevent.typeid = shared_consts.TypeNotifs.ID_EVENTS_NEW_REC
return SendNotif.saveAndSendNotif(recmyevent, req, res).then((ris) => {
return res.send({code: server_constants.RIS_CODE_OK, msg: '', id: recmyevent._id});
});
SendNotif.createNewNotification(req, res, shared_consts.TABLES_MYEVENTS, recmyevent, shared_consts.TypeNotifs.TYPEDIR_EVENTS, shared_consts.TypeNotifs.ID_EVENTS_NEW_REC);
return res.send({code: server_constants.RIS_CODE_OK, msg: '', id: recmyevent._id});
});
});
}
@@ -82,9 +79,7 @@ router.delete('/:id/:notify/:idapp', authenticate, (req, res) => {
}
if (notify === '1') {
recmyevent.typedir = shared_consts.TypeNotifs.TYPEDIR_EVENTS
recmyevent.typeid = shared_consts.TypeNotifs.ID_EVENTS_REMOVE_REC
SendNotif.saveAndSendNotif(recmyevent, req, res);
SendNotif.createNewNotification(req, res, shared_consts.TABLES_MYEVENTS, recmyevent, shared_consts.TypeNotifs.TYPEDIR_EVENTS, shared_consts.TypeNotifs.ID_EVENTS_REMOVE_REC);
}
tools.mylog('DELETED ', recmyevent.descr, recmyevent._id);