好友:特殊情况处理
This commit is contained in:
@@ -149,7 +149,7 @@ export class FriendHandler {
|
|||||||
let hisSid = await getRedis(`login_roleId_${hisRoleId}`);
|
let hisSid = await getRedis(`login_roleId_${hisRoleId}`);
|
||||||
uids.push({ uid: hisRoleId, sid: hisSid });
|
uids.push({ uid: hisRoleId, sid: hisSid });
|
||||||
}
|
}
|
||||||
console.log(JSON.stringify(uids))
|
|
||||||
this.channelService.pushMessageByUids('onFriendApply', resResult(STATUS.SUCCESS, { roleId }), uids);
|
this.channelService.pushMessageByUids('onFriendApply', resResult(STATUS.SUCCESS, { roleId }), uids);
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, {
|
return resResult(STATUS.SUCCESS, {
|
||||||
@@ -167,6 +167,7 @@ export class FriendHandler {
|
|||||||
let myFriendRelation = await FriendRelationModel.findFriendByRole(roleId, POPULATE_TYPE.NOT);
|
let myFriendRelation = await FriendRelationModel.findFriendByRole(roleId, POPULATE_TYPE.NOT);
|
||||||
let list = await FriendApplyModel.getApplyList(roleId);
|
let list = await FriendApplyModel.getApplyList(roleId);
|
||||||
let result = new Array<FriendApplyParams>();
|
let result = new Array<FriendApplyParams>();
|
||||||
|
let delApplyCodeList = new Array<string>();
|
||||||
for(let apply of list) {
|
for(let apply of list) {
|
||||||
let friend = <RoleType>apply.friend;
|
let friend = <RoleType>apply.friend;
|
||||||
let type = getRecommendType(myFriendRelation, roleId, friend.roleId);
|
let type = getRecommendType(myFriendRelation, roleId, friend.roleId);
|
||||||
@@ -178,9 +179,15 @@ export class FriendHandler {
|
|||||||
param.setServerName(serverId, serverName);
|
param.setServerName(serverId, serverName);
|
||||||
|
|
||||||
param.setType(type);
|
param.setType(type);
|
||||||
|
if(type != FRIEND_RELATION_TYPE.NORMAL) {
|
||||||
|
delApplyCodeList.push(apply.applyCode);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
result.push(param);
|
result.push(param);
|
||||||
}
|
}
|
||||||
|
await FriendApplyModel.deleteApply(delApplyCodeList);
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, {
|
return resResult(STATUS.SUCCESS, {
|
||||||
list: result
|
list: result
|
||||||
});
|
});
|
||||||
@@ -205,10 +212,13 @@ export class FriendHandler {
|
|||||||
for(let apply of applyList) {
|
for(let apply of applyList) {
|
||||||
let type = getRecommendType(myFriendRelation, roleId, apply.frdRoleId);
|
let type = getRecommendType(myFriendRelation, roleId, apply.frdRoleId);
|
||||||
if(type == FRIEND_RELATION_TYPE.HAS_FRIEND) {
|
if(type == FRIEND_RELATION_TYPE.HAS_FRIEND) {
|
||||||
str = getResStr(STATUS.FRIEND_HAS_ADD); continue;
|
str = getResStr(STATUS.FRIEND_HAS_ADD);
|
||||||
|
resultApplyCodeList.push(apply.applyCode); continue;
|
||||||
} else if(type == FRIEND_RELATION_TYPE.HAS_BLOCKED) {
|
} else if(type == FRIEND_RELATION_TYPE.HAS_BLOCKED) {
|
||||||
|
resultApplyCodeList.push(apply.applyCode);
|
||||||
str = getResStr(STATUS.FRIEND_HAS_BLOCKED); continue;
|
str = getResStr(STATUS.FRIEND_HAS_BLOCKED); continue;
|
||||||
} else if (type == FRIEND_RELATION_TYPE.MYSELF) {
|
} else if (type == FRIEND_RELATION_TYPE.MYSELF) {
|
||||||
|
resultApplyCodeList.push(apply.applyCode);
|
||||||
str = getResStr(STATUS.FRIEND_YOURSELF); continue;
|
str = getResStr(STATUS.FRIEND_YOURSELF); continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,6 +254,9 @@ export class FriendHandler {
|
|||||||
|
|
||||||
await FriendApplyModel.deleteApply(resultApplyCodeList);
|
await FriendApplyModel.deleteApply(resultApplyCodeList);
|
||||||
|
|
||||||
|
// 特殊处理:如果他点一键同意,有很多人,这个单独的人就不做这个额外的提示,直接把他好友申请删掉就好
|
||||||
|
if(str == getResStr(STATUS.FRIEND_HAS_ADD) && resultApplyCodeList.length > 1) str = '';
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, {
|
return resResult(STATUS.SUCCESS, {
|
||||||
isSuccess: str == '',
|
isSuccess: str == '',
|
||||||
msg: str,
|
msg: str,
|
||||||
@@ -377,6 +390,7 @@ export class FriendHandler {
|
|||||||
|
|
||||||
await FriendRelationModel.moveFromFriend(hisRoleId, role, friendShip, false, !!curFriend); //从对方好友删除
|
await FriendRelationModel.moveFromFriend(hisRoleId, role, friendShip, false, !!curFriend); //从对方好友删除
|
||||||
await FriendRelationModel.moveFromFriend(roleId, friend, friendShip, true, !!curFriend); // 删除好友关系并拉黑
|
await FriendRelationModel.moveFromFriend(roleId, friend, friendShip, true, !!curFriend); // 删除好友关系并拉黑
|
||||||
|
await FriendApplyModel.deleteApplyByRoles(roleId, hisRoleId); // 删除双方的申请
|
||||||
|
|
||||||
let param = new BlackListParam(friend);
|
let param = new BlackListParam(friend);
|
||||||
let isOnline = await isRoleOnline(friend.roleId);
|
let isOnline = await isRoleOnline(friend.roleId);
|
||||||
|
|||||||
@@ -64,6 +64,11 @@ export default class FriendApply extends BaseModel {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 拉黑时删除申请
|
||||||
|
public static async deleteApplyByRoles(roleId: string, frdRoleId: string) {
|
||||||
|
const result = await FriendApplyModel.deleteMany({ $or: [{ roleId, frdRoleId}, {roleId: frdRoleId, frdRoleId: roleId}] });
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static async deleteAccount(roleId: string) {
|
public static async deleteAccount(roleId: string) {
|
||||||
let result = await FriendApplyModel.deleteMany({ $or: [{ roleId: roleId }, { frdRoleId: roleId }] });
|
let result = await FriendApplyModel.deleteMany({ $or: [{ roleId: roleId }, { frdRoleId: roleId }] });
|
||||||
|
|||||||
Reference in New Issue
Block a user