This commit is contained in:
aozhiwei 2024-04-07 20:11:08 +08:00
parent 782e094efa
commit 3ac553e110
2 changed files with 49 additions and 1 deletions

View File

@ -281,7 +281,11 @@ func (this *friendMgr) AsyncAcceptApply(senderId string, targetId string, cb fun
}
func (this *friendMgr) AsyncRejectApply(senderId string, targetId string, cb func(int32, string)) {
this.asyncSetApplyStatus(senderId, targetId, 2)
if senderId == targetId {
cb(1, "")
return
}
this.asyncSetApplyStatus(senderId, targetId, constant.FRIEND_APPLY_STATUS_REJECT)
cb(0, "")
}

View File

@ -237,6 +237,50 @@ func (this *player) CMAcceptFriendRequest(hdr *f5.MsgHdr, msg *cs.CMAcceptFriend
}
func (this *player) CMRejectFriendRequest(hdr *f5.MsgHdr, msg *cs.CMRejectFriendRequest) {
rspMsg := new(cs.SMRejectFriendRequest)
if GetFriendMgr().IsFriend(this.GetAccountId(), msg.GetTargetAccountId()) {
this.SendMsg(rspMsg)
return
}
doFunc := func () {
f5.NewLockAsyncTask(
[][]string{
{constant.MEMBER_LOCK_KEY, this.GetAccountId()},
{constant.MEMBER_LOCK_KEY, msg.GetTargetAccountId()},
},
func (cb *f5.LockAsyncTask) {
GetFriendMgr().AsyncRejectApply(
this.GetAccountId(),
msg.GetTargetAccountId(),
func (errCode int32, errMsg string) {
if errCode != 0 {
this.SendMsg(rspMsg.Err(500, "server internal error"))
return
}
this.SendMsg(rspMsg)
})
})
}
f5.GetJsStyleDb().OrmSelectOne(
constant.FRIEND_DB,
"t_friend_apply",
[][]string{
{"sender_id", msg.GetTargetAccountId()},
{"target_id", this.GetAccountId()},
{"status", q5.ToString(constant.FRIEND_APPLY_STATUS_NONE)},
},
func (err error, ds *f5.DataSet) {
if err != nil {
this.SendMsg(rspMsg.Err(500, "server internal error"))
return
}
if ds.Next() {
doFunc()
} else {
this.SendMsg(rspMsg.Err(500, "server internal error"))
return
}
})
}
func (this *player) CMDeleteFriendShip(hdr *f5.MsgHdr, msg *cs.CMDeleteFriendShip) {