fix同意好友申请申请记录没有删除
This commit is contained in:
parent
1477611d4a
commit
8a9a4f0c2d
|
@ -608,38 +608,49 @@ func (this *FriendMgr) FriendAgree(p *Player, destP *model.BindFriend) {
|
|||
}
|
||||
}
|
||||
|
||||
ret, err := model.QueryFriendApplyBySnid(p.Platform, p.SnId)
|
||||
// 删除申请者的申请列表
|
||||
delApplyListFunc := func(plt string, snid int32, applySnid int32) friend.OpResultCode {
|
||||
// 删除被申请者的申请列表
|
||||
list1, err := model.QueryFriendApplyBySnid(plt, snid)
|
||||
if err != nil {
|
||||
return friend.OpResultCode_OPRC_Error
|
||||
}
|
||||
// 维护申请放和被申请方的申请列表
|
||||
//查看是否在申请列表
|
||||
if ret != nil {
|
||||
if ret.ApplySnids != nil {
|
||||
for i, as := range ret.ApplySnids {
|
||||
if as.SnId == destP.SnId {
|
||||
// 删除被申请者的申请列表
|
||||
ret.ApplySnids = append(ret.ApplySnids[:i], ret.ApplySnids[i+1:]...)
|
||||
model.UpsertFriendApply(p.Platform, p.SnId, ret)
|
||||
|
||||
// 删除发起方的申请列表
|
||||
data, err := model.QueryFriendApplyListBySnid(p.Platform, destP.SnId)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("QueryFriendApplyListBySnid err:%v", err)
|
||||
} else {
|
||||
if data == nil {
|
||||
data = model.NewApplyList(destP.SnId)
|
||||
}
|
||||
for k, v := range data.List {
|
||||
if v == p.SnId {
|
||||
data.List = append(data.List[:k], data.List[k+1:]...)
|
||||
model.UpsertApplyList(p.Platform, data)
|
||||
applyList = data.List
|
||||
for k, v := range list1.ApplySnids {
|
||||
if v.SnId == applySnid {
|
||||
list1.ApplySnids = append(list1.ApplySnids[:k], list1.ApplySnids[k+1:]...)
|
||||
model.UpsertFriendApply(plt, snid, list1)
|
||||
break
|
||||
}
|
||||
}
|
||||
// 删除发起方的申请列表
|
||||
list2, err := model.QueryFriendApplyListBySnid(plt, applySnid)
|
||||
if err != nil {
|
||||
return friend.OpResultCode_OPRC_Error
|
||||
}
|
||||
for k, v := range list2.List {
|
||||
if v == snid {
|
||||
list2.List = append(list2.List[:k], list2.List[k+1:]...)
|
||||
model.UpsertApplyList(plt, list2)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if applySnid == destP.SnId {
|
||||
applyList = list2.List
|
||||
}
|
||||
|
||||
return friend.OpResultCode_OPRC_Sucess
|
||||
}
|
||||
|
||||
//查看是否在申请列表
|
||||
code := delApplyListFunc(p.Platform, p.SnId, destP.SnId)
|
||||
if code != friend.OpResultCode_OPRC_Sucess {
|
||||
return code
|
||||
}
|
||||
code = delApplyListFunc(p.Platform, destP.SnId, p.SnId)
|
||||
if code != friend.OpResultCode_OPRC_Sucess {
|
||||
return code
|
||||
}
|
||||
// 保存好友关系
|
||||
if friendDB != nil {
|
||||
friendDB.BindFriend = append(friendDB.BindFriend, &model.BindFriend{
|
||||
|
@ -647,12 +658,9 @@ func (this *FriendMgr) FriendAgree(p *Player, destP *model.BindFriend) {
|
|||
CreateTime: time.Now().Unix(),
|
||||
})
|
||||
model.UpsertFriend(friendDB)
|
||||
return friend.OpResultCode_OPRC_Sucess
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return friend.OpResultCode_OPRC_Error
|
||||
}), task.CompleteNotifyWrapper(func(data interface{}, tt task.Task) {
|
||||
if data != nil {
|
||||
|
|
Loading…
Reference in New Issue