Friendship Accepted and Refused (notification updated)

This commit is contained in:
Paolo Arena
2022-07-27 20:56:01 +02:00
parent 3515914f17
commit 50c6031789
10 changed files with 151 additions and 49 deletions

View File

@@ -1597,8 +1597,7 @@ UserSchema.statics.setFriendsCmd = async function(idapp, usernameOrig, usernameD
// CREATE NOTIFICATION IN TABLE SENDNOTIF
const req = tools.getReqByPar(idapp, usernameOrig);
SendNotif.createNewNotifToSingleUser(req, null, usernameDest, true, shared_consts.TypeNotifs.TYPEDIR_FRIENDS, shared_consts.TypeNotifs.ID_FRIENDS_ACCEPTED);
await SendNotif.createNewNotifToSingleUser(req, null, {usernameDest}, true, shared_consts.TypeNotifs.TYPEDIR_FRIENDS, shared_consts.TypeNotifs.ID_FRIENDS_ACCEPTED);
update = {$pull: {'profile.req_friends': {username: {$in: [usernameDest]}}}};
ris = await User.updateOne({idapp, username: usernameOrig}, update);
@@ -1677,6 +1676,10 @@ UserSchema.statics.setFriendsCmd = async function(idapp, usernameOrig, usernameD
} else if (cmd === shared_consts.FRIENDSCMD.CANCEL_REQ_FRIEND) {
// CREATE NOTIFICATION IN TABLE SENDNOTIF
const req = tools.getReqByPar(idapp, usernameOrig);
await SendNotif.createNewNotifToSingleUser(req, null, {usernameDest}, true, shared_consts.TypeNotifs.TYPEDIR_FRIENDS, shared_consts.TypeNotifs.ID_FRIENDS_REFUSED);
await this.removeReqFriend(idapp, usernameDest, usernameOrig); // Rimuovo la Richiesta di Amicizia da lui
ris = await this.removeFriend(idapp, usernameOrig, usernameDest); // Rimuovo l'Amicizia da me
@@ -1737,6 +1740,11 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD
};
ris = await User.updateOne({idapp, username: usernameOrig}, update);
// CREATE NOTIFICATION IN TABLE SENDNOTIF
const req = tools.getReqByPar(idapp, usernameOrig);
SendNotif.createNewNotifToSingleUser(req, null, {usernameDest, groupnameDest}, true, shared_consts.TypeNotifs.TYPEDIR_GROUPS, shared_consts.TypeNotifs.ID_GROUP_ACCEPTED);
// Elimina la richiesta:
update = {$pull: {req_users: {username: {$in: [usernameOrig]}}}};
ris = await MyGroup.updateOne({idapp, groupname: groupnameDest},