新加好友时推送助战英雄

This commit is contained in:
wh_zcy 2022-11-25 23:31:25 +08:00
parent d4c953dc17
commit 473f0e7d06

View File

@ -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++