fix 好友申请列表
This commit is contained in:
parent
211283fc65
commit
b76949b468
|
|
@ -564,13 +564,69 @@ func (this *FriendMgr) FriendAgree(p *Player, destP *model.BindFriend) {
|
||||||
}
|
}
|
||||||
logger.Logger.Tracef(">>FriendAgree %d -> %d, %v", p.SnId, destP.SnId, pack)
|
logger.Logger.Tracef(">>FriendAgree %d -> %d, %v", p.SnId, destP.SnId, pack)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 删除申请者的申请列表
|
||||||
|
delApplyListFunc := func(plt string, snid int32, applySnid int32) friend.OpResultCode {
|
||||||
|
// 删除被申请者的申请列表
|
||||||
|
list1, err := model.QueryFriendApplyBySnid(plt, snid)
|
||||||
|
if err != nil {
|
||||||
|
logger.Logger.Errorf("QueryFriendApplyBySnid %v error: %v", snid, err)
|
||||||
|
return friend.OpResultCode_OPRC_Error
|
||||||
|
}
|
||||||
|
if list1 != nil {
|
||||||
|
k := 0
|
||||||
|
for k < len(list1.ApplySnids) {
|
||||||
|
if list1.ApplySnids[k].SnId == applySnid {
|
||||||
|
list1.ApplySnids = append(list1.ApplySnids[:k], list1.ApplySnids[k+1:]...)
|
||||||
|
model.UpsertFriendApply(plt, snid, list1)
|
||||||
|
} else {
|
||||||
|
k++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 删除发起方的申请列表
|
||||||
|
list2, err := model.QueryFriendApplyListBySnid(plt, applySnid)
|
||||||
|
if err != nil {
|
||||||
|
logger.Logger.Errorf("QueryFriendApplyListBySnid %v error: %v", applySnid, err)
|
||||||
|
return friend.OpResultCode_OPRC_Error
|
||||||
|
}
|
||||||
|
if list2 != nil {
|
||||||
|
k := 0
|
||||||
|
for k < len(list2.List) {
|
||||||
|
if list2.List[k] == snid {
|
||||||
|
list2.List = append(list2.List[:k], list2.List[k+1:]...)
|
||||||
|
model.UpsertApplyList(plt, list2)
|
||||||
|
} else {
|
||||||
|
k++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if applySnid == destP.SnId && list2 != nil {
|
||||||
|
applyList = list2.List
|
||||||
|
}
|
||||||
|
|
||||||
|
if applySnid == p.SnId && list2 != nil {
|
||||||
|
meApplyList = list2.List
|
||||||
|
}
|
||||||
|
|
||||||
|
return friend.OpResultCode_OPRC_Sucess
|
||||||
|
}
|
||||||
|
|
||||||
me := FriendMgrSingleton.GetPlayer(p.Platform, p.SnId)
|
me := FriendMgrSingleton.GetPlayer(p.Platform, p.SnId)
|
||||||
if me == nil {
|
if me == nil {
|
||||||
SendToClick(friend.OpResultCode_OPRC_Error)
|
SendToClick(friend.OpResultCode_OPRC_Error)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if FriendMgrSingleton.IsFriend(p.Platform, p.SnId, destP.SnId) { //已经是好友了
|
if FriendMgrSingleton.IsFriend(p.Platform, p.SnId, destP.SnId) { //已经是好友了
|
||||||
SendToClick(friend.OpResultCode_OPRC_Friend_AlreadyAdd)
|
// 删除申请者的申请列表
|
||||||
|
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||||
|
delApplyListFunc(p.Platform, p.SnId, destP.SnId)
|
||||||
|
delApplyListFunc(p.Platform, destP.SnId, p.SnId)
|
||||||
|
return nil
|
||||||
|
}), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) {
|
||||||
|
SendToClick(friend.OpResultCode_OPRC_Friend_AlreadyAdd)
|
||||||
|
})).StartByFixExecutor(FriendWrite)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//验证自己
|
//验证自己
|
||||||
|
|
@ -612,54 +668,6 @@ func (this *FriendMgr) FriendAgree(p *Player, destP *model.BindFriend) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除申请者的申请列表
|
|
||||||
delApplyListFunc := func(plt string, snid int32, applySnid int32) friend.OpResultCode {
|
|
||||||
// 删除被申请者的申请列表
|
|
||||||
list1, err := model.QueryFriendApplyBySnid(plt, snid)
|
|
||||||
if err != nil {
|
|
||||||
logger.Logger.Errorf("QueryFriendApplyBySnid %v error: %v", snid, err)
|
|
||||||
return friend.OpResultCode_OPRC_Error
|
|
||||||
}
|
|
||||||
if list1 != nil {
|
|
||||||
k := 0
|
|
||||||
for k < len(list1.ApplySnids) {
|
|
||||||
if list1.ApplySnids[k].SnId == applySnid {
|
|
||||||
list1.ApplySnids = append(list1.ApplySnids[:k], list1.ApplySnids[k+1:]...)
|
|
||||||
model.UpsertFriendApply(plt, snid, list1)
|
|
||||||
} else {
|
|
||||||
k++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 删除发起方的申请列表
|
|
||||||
list2, err := model.QueryFriendApplyListBySnid(plt, applySnid)
|
|
||||||
if err != nil {
|
|
||||||
logger.Logger.Errorf("QueryFriendApplyListBySnid %v error: %v", applySnid, err)
|
|
||||||
return friend.OpResultCode_OPRC_Error
|
|
||||||
}
|
|
||||||
if list2 != nil {
|
|
||||||
k := 0
|
|
||||||
for k < len(list2.List) {
|
|
||||||
if list2.List[k] == snid {
|
|
||||||
list2.List = append(list2.List[:k], list2.List[k+1:]...)
|
|
||||||
model.UpsertApplyList(plt, list2)
|
|
||||||
} else {
|
|
||||||
k++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if applySnid == destP.SnId && list2 != nil {
|
|
||||||
applyList = list2.List
|
|
||||||
}
|
|
||||||
|
|
||||||
if applySnid == p.SnId && list2 != nil {
|
|
||||||
meApplyList = list2.List
|
|
||||||
}
|
|
||||||
|
|
||||||
return friend.OpResultCode_OPRC_Sucess
|
|
||||||
}
|
|
||||||
|
|
||||||
//查看是否在申请列表
|
//查看是否在申请列表
|
||||||
code := delApplyListFunc(p.Platform, p.SnId, destP.SnId)
|
code := delApplyListFunc(p.Platform, p.SnId, destP.SnId)
|
||||||
if code != friend.OpResultCode_OPRC_Sucess {
|
if code != friend.OpResultCode_OPRC_Sucess {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue