From a52d674a14cdd305418d2a20e35de4dcb391dfd8 Mon Sep 17 00:00:00 2001 From: wenxu12345 <44203734@qq.com> Date: Wed, 29 Dec 2021 16:52:12 +0800 Subject: [PATCH] Refactor code --- internal/rpc/friend/firend.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/rpc/friend/firend.go b/internal/rpc/friend/firend.go index bfcb46467..7acb2e7dd 100644 --- a/internal/rpc/friend/firend.go +++ b/internal/rpc/friend/firend.go @@ -184,6 +184,7 @@ func (s *friendServer) ImportFriend(ctx context.Context, req *pbFriend.ImportFri for _, v := range req.FriendUserIDList { if _, fErr := imdb.GetUserByUserID(v); fErr != nil { + log.NewError(req.OperationID, "GetUserByUserID failed", req.FromUserID, fErr.Error(), v) resp.UserIDResultList = append(resp.UserIDResultList, &pbFriend.UserIDResult{UserID: v, Result: -1}) } else { if _, err := imdb.GetFriendRelationshipFromFriend(req.FromUserID, v); err != nil { @@ -202,10 +203,8 @@ func (s *friendServer) ImportFriend(ctx context.Context, req *pbFriend.ImportFri resp.UserIDResultList = append(resp.UserIDResultList, &pbFriend.UserIDResult{UserID: v, Result: -1}) continue } - for _, v := range req.FriendUserIDList { - chat.FriendAddedNotification(req.OperationID, req.OpUserID, req.FromUserID, v) - resp.UserIDResultList = append(resp.UserIDResultList, &pbFriend.UserIDResult{UserID: v, Result: 0}) - } + resp.UserIDResultList = append(resp.UserIDResultList, &pbFriend.UserIDResult{UserID: v, Result: 0}) + chat.FriendAddedNotification(req.OperationID, req.OpUserID, req.FromUserID, v) } } }