Error code standardization

This commit is contained in:
skiffer-git
2023-02-14 11:33:10 +08:00
parent b7d724a5e4
commit 05d00a8174
7 changed files with 78 additions and 35 deletions
+10 -8
View File
@@ -3,7 +3,7 @@ package friend
import (
"Open_IM/internal/common/check"
"Open_IM/internal/common/convert"
chat "Open_IM/internal/common/notification"
"Open_IM/internal/common/notification"
"Open_IM/internal/common/rpcserver"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
@@ -26,6 +26,8 @@ type friendServer struct {
*rpcserver.RpcServer
controller.FriendInterface
controller.BlackInterface
notification *notification.Check
userCheck *check.UserCheck
}
func NewFriendServer(port int) *friendServer {
@@ -105,7 +107,7 @@ func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbFriend.Apply
if req.ToUserID == req.FromUserID {
return nil, constant.ErrCanNotAddYourself.Wrap()
}
if _, err := check.GetUsersInfo(ctx, req.ToUserID, req.FromUserID); err != nil {
if _, err := s.userCheck.GetUsersInfoMap(ctx, []string{req.ToUserID, req.FromUserID}, true); err != nil {
return nil, err
}
in1, in2, err := s.FriendInterface.CheckIn(ctx, req.FromUserID, req.ToUserID)
@@ -118,7 +120,7 @@ func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbFriend.Apply
if err = s.FriendInterface.AddFriendRequest(ctx, req.FromUserID, req.ToUserID, req.ReqMsg, req.Ex); err != nil {
return nil, err
}
chat.FriendApplicationAddNotification(ctx, req)
s.notification.FriendApplicationAddNotification(ctx, req)
return resp, nil
}
@@ -128,7 +130,7 @@ func (s *friendServer) ImportFriends(ctx context.Context, req *pbFriend.ImportFr
if err := tokenverify.CheckAdmin(ctx); err != nil {
return nil, err
}
if _, err := check.NewUserCheck().GetUsersInfos(ctx, append([]string{req.OwnerUserID}, req.FriendUserIDs...), true); err != nil {
if _, err := s.userCheck.GetUsersInfos(ctx, append([]string{req.OwnerUserID}, req.FriendUserIDs...), true); err != nil {
return nil, err
}
@@ -157,7 +159,7 @@ func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbFriend.Res
if err != nil {
return nil, err
}
chat.FriendApplicationAgreedNotification(ctx, req)
s.notification.FriendApplicationAgreedNotification(ctx, req)
return resp, nil
}
if req.HandleResult == constant.FriendResponseRefuse {
@@ -165,7 +167,7 @@ func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbFriend.Res
if err != nil {
return nil, err
}
chat.FriendApplicationRefusedNotification(ctx, req)
s.notification.FriendApplicationRefusedNotification(ctx, req)
return resp, nil
}
return nil, constant.ErrArgs.Wrap("req.HandleResult != -1/1")
@@ -184,7 +186,7 @@ func (s *friendServer) DeleteFriend(ctx context.Context, req *pbFriend.DeleteFri
if err := s.FriendInterface.Delete(ctx, req.OwnerUserID, []string{req.FriendUserID}); err != nil {
return nil, err
}
chat.FriendDeletedNotification(ctx, req)
s.notification.FriendDeletedNotification(ctx, req)
return resp, nil
}
@@ -201,7 +203,7 @@ func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbFriend.SetFri
if err := s.FriendInterface.UpdateRemark(ctx, req.OwnerUserID, req.FriendUserID, req.Remark); err != nil {
return nil, err
}
chat.FriendRemarkSetNotification(ctx, req.OwnerUserID, req.FriendUserID)
s.notification.FriendRemarkSetNotification(ctx, req.OwnerUserID, req.FriendUserID)
return resp, nil
}
+7 -4
View File
@@ -1,8 +1,9 @@
package user
import (
"Open_IM/internal/common/check"
"Open_IM/internal/common/convert"
chat "Open_IM/internal/common/notification"
"Open_IM/internal/common/notification"
"Open_IM/internal/common/rpcserver"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
@@ -25,6 +26,8 @@ import (
type userServer struct {
*rpcserver.RpcServer
controller.UserInterface
notification *notification.Check
userCheck *check.UserCheck
}
func NewUserServer(port int) *userServer {
@@ -226,11 +229,11 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbuser.UpdateUserI
}
go func() {
for _, v := range friends {
chat.FriendInfoUpdatedNotification(ctx, req.UserInfo.UserID, v.FriendUser.UserID, tracelog.GetOpUserID(ctx))
s.notification.FriendInfoUpdatedNotification(ctx, req.UserInfo.UserID, v.FriendUser.UserID, tracelog.GetOpUserID(ctx))
}
}()
chat.UserInfoUpdatedNotification(ctx, tracelog.GetOpUserID(ctx), req.UserInfo.UserID)
s.notification.UserInfoUpdatedNotification(ctx, tracelog.GetOpUserID(ctx), req.UserInfo.UserID)
return resp, nil
}
@@ -246,7 +249,7 @@ func (s *userServer) SetGlobalRecvMessageOpt(ctx context.Context, req *pbuser.Se
if err := s.UpdateByMap(ctx, req.UserID, m); err != nil {
return nil, err
}
chat.UserInfoUpdatedNotification(ctx, req.UserID, req.UserID)
s.notification.UserInfoUpdatedNotification(ctx, req.UserID, req.UserID)
return resp, nil
}