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

@@ -1559,6 +1559,8 @@ UserSchema.statics.removeReqFriend = async function(
UserSchema.statics.setFriendsCmd = async function(idapp, usernameOrig, usernameDest, cmd, value) {
const {SendNotif} = require('../models/sendnotif');
let ris = null;
let update = {};
try {
@@ -1593,6 +1595,11 @@ UserSchema.statics.setFriendsCmd = async function(idapp, usernameOrig, usernameD
};
ris = await User.updateOne({idapp, username: usernameOrig}, update);
// 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);
update = {$pull: {'profile.req_friends': {username: {$in: [usernameDest]}}}};
ris = await User.updateOne({idapp, username: usernameOrig}, update);
}