好友:拉黑bug,添加申请等推送

This commit is contained in:
luying
2021-02-05 18:22:15 +08:00
parent e1e36275c0
commit 97d2bea767
4 changed files with 45 additions and 19 deletions

View File

@@ -62,22 +62,30 @@ export default class FriendRelation extends BaseModel {
return result;
}
public static async moveFromFriend(roleId: string, friend: RoleType, friendShip: FriendShipType, toBlack: boolean ) {
let update = {
$pull: { friends: { roleId: friend.roleId } }
public static async moveFromFriend(roleId: string, friend: RoleType, friendShip: FriendShipType, toBlack: boolean, hasFriend: boolean ) {
let update = {}
let setOnInsert = {};
if(hasFriend) {
update['$pull'] = { friends: { roleId: friend.roleId } };
} else {
setOnInsert['friends'] = [];
}
if(toBlack) {
update['$push'] = { blacklist: { roleId: friend.roleId, role: friend._id, friendShip: friendShip? friendShip._id: null } };
} else {
setOnInsert['blacklist'] = [];
}
update['$setOnInsert'] = setOnInsert;
let result: FriendRelationType = await FriendRelationModel.findOneAndUpdate({ roleId }, update, { new: true });
let result: FriendRelationType = await FriendRelationModel.findOneAndUpdate({ roleId }, update, { upsert: true, new: true });
return result
}
public static async removeFromBlack(roleId: string, frdRoleId: string ) {
let result: FriendRelationType = await FriendRelationModel.findOneAndUpdate({ roleId }, {
$pull: { blacklist: { roleId: frdRoleId } }
}, { new: true });
$pull: { blacklist: { roleId: frdRoleId } },
$setOnInsert: { friends: [] }
}, { upsert: true, new: true });
return result
}

View File

@@ -60,7 +60,7 @@ export const FRIEND = {
FRIEND_CLOSEPOINT_ADD: 5, // 每赠送/领取一次增加的亲密度
FRIEND_FRIENDPOINT_ADD: 1, // 每领取一次爱心会增加的情谊值
FRIEND_RECONMMEND_LEVEL: 5, // 系统推荐玩家等级要求浮动
FRIEND_RECONMMEND_ACTIVETIME: 24, // 系统推荐玩家活跃时间要求(小时)
FRIEND_RECONMMEND_ACTIVETIME: 1000, // 系统推荐玩家活跃时间要求(小时)
FRIEND_BLACKLIST_MAX: 100, // 黑名单人数上限
FRIEND_MANAGE_APPLICATION: 50, // 好友显示收到的申请条数上限
FRIEND_RECEIVE_SINGLE: 1, // 向单个好友每日最多赠送多少爱心