From 473f0e7d062f910364f15daec58ec8d1a5c9783e Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Fri, 25 Nov 2022 23:31:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=8A=A0=E5=A5=BD=E5=8F=8B=E6=97=B6?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E5=8A=A9=E6=88=98=E8=8B=B1=E9=9B=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/friend/api_cross_agree.go | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/modules/friend/api_cross_agree.go b/modules/friend/api_cross_agree.go index 16faeb3fe..8f7346271 100644 --- a/modules/friend/api_cross_agree.go +++ b/modules/friend/api_cross_agree.go @@ -52,6 +52,21 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.FriendAgreeReq) (c } } + pushAssistHero := func(uid, friendId, heroObjId string) { + //把设置的助战英雄推送给好友 + push := &pb.FriendAssistHeroUpdatePush{ + Friend: &pb.FriendBase{ + UserId: uid, + HeroObjId: heroObjId, + }, + } + + this.moduleFriend.Debug("设置的助战英雄推送给好友", log.Fields{"uid": uid, "heroObjId": heroObjId}) + if err := this.moduleFriend.SendMsgToUsers(string(this.moduleFriend.GetType()), "assistheroupdate", push, friendId); err != nil { + this.moduleFriend.Error("推送助战英雄列表", log.Fields{"uid": uid, "err": err.Error()}) + } + } + //将目标加入到自己的好友列表中 for _, userId := range agreeIds { if _, ok := utils.Find(self.FriendIds, userId); !ok { @@ -73,15 +88,24 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.FriendAgreeReq) (c } target.FriendIds = append(target.FriendIds, self.Uid) } - err = this.moduleFriend.modelFriend.Change(target.Uid, map[string]interface{}{ + if err = this.moduleFriend.modelFriend.Change(target.Uid, map[string]interface{}{ "friendIds": target.FriendIds, - }) - if err != nil { + }); err != nil { code = pb.ErrorCode_DBError this.moduleFriend.Error("好友审批同意", log.Fields{"uid": uid, "params": req.FriendIds, "err": err.Error()}) return } + //将目标的助战英雄推给自己 + if target.AssistHeroId != "" { + pushAssistHero(target.Uid, self.Uid, target.AssistHeroId) + } + + // 将自己的助战英雄推个新加入的好友 + if self.AssistHeroId != "" { + pushAssistHero(self.Uid, target.Uid, self.AssistHeroId) + } + //将目标从申请列表中删除 self.ApplyIds = utils.DeleteString(self.ApplyIds, userId) optNum++