diff --git a/server/imserver_new/friend/friendmgr.go b/server/imserver_new/friend/friendmgr.go index 35c158f6..a24dc040 100644 --- a/server/imserver_new/friend/friendmgr.go +++ b/server/imserver_new/friend/friendmgr.go @@ -178,11 +178,70 @@ func (this *friendMgr) AsyncGetApplyList(lastIdx int64, accountId string, cb fun } func (this *friendMgr) AsyncAddFriend(senderId string, targetId string, cb func(int32, string)) { - } func (this *friendMgr) AsyncAccpetApply(senderId string, targetId string, cb func(int32, string)) { + if senderId == targetId { + cb(1, "") + return + } + queryCb := func () { + if this.IsFriend(senderId, targetId) { + f5.GetJsStyleDb().Update( + constant.FRIEND_DB, + "t_friend_apply", + [][]string{ + {"status", "1"}, + }, + [][]string{ + {"sender_id", senderId}, + {"target_id", targetId}, + {"status", "0"}, + }, + func (err error, lastInsertId int64, rowsAffected int64) { + }) + cb(0, "") + return + } else { + f5.GetJsStyleDb().Upsert( + constant.FRIEND_DB, + "t_friend_relationship", + [][]string{ + {"sender_id", senderId}, + {"target_id", targetId}, + {"status", "0"}, + }, + [][]string{ + {"sender_id", senderId}, + {"target_id", targetId}, + {"status", "0"}, + }, + [][]string{ + {"sender_id", senderId}, + {"target_id", targetId}, + {"status", "0"}, + }, + func (err error, lastInsertId int64, rowsAffected int64) { + + }) + } + } + f5.GetJsStyleDb().OrmSelectOne( + constant.FRIEND_DB, + "t_friend_apply", + [][]string{ + {"sender_id", senderId}, + {"target_id", targetId}, + {"status", "0"}, + }, + func (err error, ds *f5.DataSet) { + if err != nil { + cb(1, "") + return + } + queryCb() + }) } func (this *friendMgr) AsyncRejectApply(senderId string, targetId string, cb func(int32, string)) { diff --git a/server/imserver_new/player/player.go b/server/imserver_new/player/player.go index b958dd6f..1c4fa8f2 100644 --- a/server/imserver_new/player/player.go +++ b/server/imserver_new/player/player.go @@ -172,7 +172,8 @@ func (this *player) CMAddFriendRequest(hdr *f5.MsgHdr, msg *cs.CMAddFriendReques this.GetAccountId(), msg.GetTargetAccountId(), func (errCode int32, errMsg string) { - + this.SendMsg(rspMsg.Err(errCode, errMsg)) + return }) }