Notification: Set a new Friendship and Accepted Friendship
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user