back err_name (#1976)

Signed-off-by: xuan <146319162+wxuanF@users.noreply.github.com>
pull/1991/head
xuan 10 months ago committed by GitHub
parent 57331182c2
commit 1ef26b29a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -70,7 +70,7 @@ func StartTransfer(prometheusPort int) error {
return err
}
if err2 := client.CreateRpcRootNodes(config.Config.GetServiceNames()); err2 != nil {
if err := client.CreateRpcRootNodes(config.Config.GetServiceNames()); err != nil {
return err
}
client.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, "round_robin")))

@ -28,7 +28,7 @@ import (
)
func (s *friendServer) GetPaginationBlacks(ctx context.Context, req *pbfriend.GetPaginationBlacksReq) (resp *pbfriend.GetPaginationBlacksResp, err error) {
if accessErr := s.userRpcClient.Access(ctx, req.UserID); accessErr != nil {
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
return nil, err
}
total, blacks, err := s.blackDatabase.FindOwnerBlacks(ctx, req.UserID, req.Pagination)

@ -115,7 +115,7 @@ func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) (resp *pbfriend.ApplyToAddFriendResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
resp = &pbfriend.ApplyToAddFriendResp{}
if accessErr := authverify.CheckAccessV3(ctx, req.FromUserID); accessErr != nil {
if err := authverify.CheckAccessV3(ctx, req.FromUserID); err != nil {
return nil, err
}
if req.ToUserID == req.FromUserID {
@ -124,7 +124,7 @@ func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbfriend.Apply
if err = CallbackBeforeAddFriend(ctx, req); err != nil && err != errs.ErrCallbackContinue {
return nil, err
}
if _, getUserInfoErr := s.userRpcClient.GetUsersInfoMap(ctx, []string{req.ToUserID, req.FromUserID}); getUserInfoErr != nil {
if _, err := s.userRpcClient.GetUsersInfoMap(ctx, []string{req.ToUserID, req.FromUserID}); err != nil {
return nil, err
}
in1, in2, err := s.friendDatabase.CheckIn(ctx, req.FromUserID, req.ToUserID)
@ -219,7 +219,7 @@ func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbfriend.Res
func (s *friendServer) DeleteFriend(ctx context.Context, req *pbfriend.DeleteFriendReq) (resp *pbfriend.DeleteFriendResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
resp = &pbfriend.DeleteFriendResp{}
if accessErr := s.userRpcClient.Access(ctx, req.OwnerUserID); accessErr != nil {
if err := s.userRpcClient.Access(ctx, req.OwnerUserID); err != nil {
return nil, err
}
_, err = s.friendDatabase.FindFriendsWithError(ctx, req.OwnerUserID, []string{req.FriendUserID})
@ -244,7 +244,7 @@ func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbfriend.SetFri
return nil, err
}
resp = &pbfriend.SetFriendRemarkResp{}
if accessErr := s.userRpcClient.Access(ctx, req.OwnerUserID); accessErr != nil {
if err := s.userRpcClient.Access(ctx, req.OwnerUserID); err != nil {
return nil, err
}
_, err = s.friendDatabase.FindFriendsWithError(ctx, req.OwnerUserID, []string{req.FriendUserID})
@ -295,7 +295,7 @@ func (s *friendServer) GetDesignatedFriendsApply(ctx context.Context,
// ok 获取接收到的好友申请(即别人主动申请的).
func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *pbfriend.GetPaginationFriendsApplyToReq) (resp *pbfriend.GetPaginationFriendsApplyToResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
if accessErr := s.userRpcClient.Access(ctx, req.UserID); accessErr != nil {
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
return nil, err
}
total, friendRequests, err := s.friendDatabase.PageFriendRequestToMe(ctx, req.UserID, req.Pagination)
@ -315,7 +315,7 @@ func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *pbf
func (s *friendServer) GetPaginationFriendsApplyFrom(ctx context.Context, req *pbfriend.GetPaginationFriendsApplyFromReq) (resp *pbfriend.GetPaginationFriendsApplyFromResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
resp = &pbfriend.GetPaginationFriendsApplyFromResp{}
if accessErr := s.userRpcClient.Access(ctx, req.UserID); accessErr != nil {
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
return nil, err
}
total, friendRequests, err := s.friendDatabase.PageFriendRequestFromMe(ctx, req.UserID, req.Pagination)
@ -343,7 +343,7 @@ func (s *friendServer) IsFriend(ctx context.Context, req *pbfriend.IsFriendReq)
func (s *friendServer) GetPaginationFriends(ctx context.Context, req *pbfriend.GetPaginationFriendsReq) (resp *pbfriend.GetPaginationFriendsResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
if accessErr := s.userRpcClient.Access(ctx, req.UserID); accessErr != nil {
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
return nil, err
}
total, friends, err := s.friendDatabase.PageOwnerFriends(ctx, req.UserID, req.Pagination)
@ -361,7 +361,7 @@ func (s *friendServer) GetPaginationFriends(ctx context.Context, req *pbfriend.G
func (s *friendServer) GetFriendIDs(ctx context.Context, req *pbfriend.GetFriendIDsReq) (resp *pbfriend.GetFriendIDsResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
if accessErr := s.userRpcClient.Access(ctx, req.UserID); accessErr != nil {
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
return nil, err
}
resp = &pbfriend.GetFriendIDsResp{}

@ -539,7 +539,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbgroup.KickGrou
if err != nil {
return nil, err
}
if populateErr := s.PopulateGroupMember(ctx, members...); populateErr != nil {
if err := s.PopulateGroupMember(ctx, members...); err != nil {
return nil, err
}
memberMap := make(map[string]*relationtb.GroupMemberModel)
@ -765,12 +765,12 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbgroup
return nil, errs.ErrGroupRequestHandled.Wrap("group request already processed")
}
var inGroup bool
if _, takeErr := s.db.TakeGroupMember(ctx, req.GroupID, req.FromUserID); takeErr == nil {
if _, err := s.db.TakeGroupMember(ctx, req.GroupID, req.FromUserID); err == nil {
inGroup = true // 已经在群里了
} else if !s.IsNotFound(err) {
return nil, err
}
if _, getInfoErr := s.User.GetPublicUserInfo(ctx, req.FromUserID); getInfoErr != nil {
if _, err := s.User.GetPublicUserInfo(ctx, req.FromUserID); err != nil {
return nil, err
}
var member *relationtb.GroupMemberModel
@ -857,14 +857,14 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbgroup.JoinGroupReq)
JoinTime: time.Now(),
MuteEndTime: time.UnixMilli(0),
}
if callbackErr := CallbackBeforeMemberJoinGroup(ctx, groupMember, group.Ex); callbackErr != nil {
if err := CallbackBeforeMemberJoinGroup(ctx, groupMember, group.Ex); err != nil {
return nil, err
}
if createErr := s.db.CreateGroup(ctx, nil, []*relationtb.GroupMemberModel{groupMember}); createErr != nil {
if err := s.db.CreateGroup(ctx, nil, []*relationtb.GroupMemberModel{groupMember}); err != nil {
return nil, err
}
if createErr := s.conversationRpcClient.GroupChatFirstCreateConversation(ctx, req.GroupID, []string{req.InviterUserID}); createErr != nil {
if err := s.conversationRpcClient.GroupChatFirstCreateConversation(ctx, req.GroupID, []string{req.InviterUserID}); err != nil {
return nil, err
}
s.Notification.MemberEnterNotification(ctx, req.GroupID, req.InviterUserID)
@ -905,7 +905,7 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbgroup.QuitGroupReq)
if member.RoleLevel == constant.GroupOwner {
return nil, errs.ErrNoPermission.Wrap("group owner can't quit")
}
if populateErr := s.PopulateGroupMember(ctx, member); populateErr != nil {
if err := s.PopulateGroupMember(ctx, member); err != nil {
return nil, err
}
err = s.db.DeleteGroupMember(ctx, req.GroupID, []string{req.UserID})
@ -967,7 +967,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbgroup.SetGroupInf
if err != nil {
return nil, err
}
if populateErr := s.PopulateGroupMember(ctx, owner); populateErr != nil {
if err := s.PopulateGroupMember(ctx, owner); err != nil {
return nil, err
}
update := UpdateGroupInfoMap(ctx, req.GroupInfoForSet)
@ -1168,7 +1168,7 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbgrou
if err != nil {
return nil, err
}
if populateErr := s.PopulateGroupMember(ctx, owners...); populateErr != nil {
if err := s.PopulateGroupMember(ctx, owners...); err != nil {
return nil, err
}
ownerMap := utils.SliceToMap(owners, func(e *relationtb.GroupMemberModel) string {
@ -1200,7 +1200,7 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbgroup.DismissGrou
return nil, errs.ErrNoPermission.Wrap("not group owner")
}
}
if populateErr := s.PopulateGroupMember(ctx, owner); populateErr != nil {
if err := s.PopulateGroupMember(ctx, owner); err != nil {
return nil, err
}
group, err := s.db.TakeGroup(ctx, req.GroupID)
@ -1210,7 +1210,7 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbgroup.DismissGrou
if !req.DeleteMember && group.Status == constant.GroupStatusDismissed {
return nil, errs.ErrDismissedAlready.Wrap("group status is dismissed")
}
if dismissErr := s.db.DismissGroup(ctx, req.GroupID, req.DeleteMember); dismissErr != nil {
if err := s.db.DismissGroup(ctx, req.GroupID, req.DeleteMember); err != nil {
return nil, err
}
if !req.DeleteMember {
@ -1566,7 +1566,7 @@ func (s *groupServer) GetGroupUsersReqApplicationList(ctx context.Context, req *
if err != nil {
return nil, err
}
if populateErr := s.PopulateGroupMember(ctx, owners...); populateErr != nil {
if err := s.PopulateGroupMember(ctx, owners...); err != nil {
return nil, err
}
ownerMap := utils.SliceToMap(owners, func(e *relationtb.GroupMemberModel) string {

@ -82,7 +82,7 @@ func (m *msgServer) SetConversationHasReadSeq(
if req.HasReadSeq > maxSeq {
return nil, errs.ErrArgs.Wrap("hasReadSeq must not be bigger than maxSeq")
}
if setErr := m.MsgDatabase.SetHasReadSeq(ctx, req.UserID, req.ConversationID, req.HasReadSeq); setErr != nil {
if err := m.MsgDatabase.SetHasReadSeq(ctx, req.UserID, req.ConversationID, req.HasReadSeq); err != nil {
return nil, err
}
if err = m.sendMarkAsReadNotification(ctx, req.ConversationID, constant.SingleChatType, req.UserID,

@ -68,7 +68,7 @@ func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.
if !authverify.IsAppManagerUid(ctx) {
switch msgs[0].SessionType {
case constant.SingleChatType:
if accessErr := authverify.CheckAccessV3(ctx, msgs[0].SendID); accessErr != nil {
if err := authverify.CheckAccessV3(ctx, msgs[0].SendID); err != nil {
return nil, err
}
role = user.AppMangerLevel
@ -133,7 +133,7 @@ func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.
} else {
recvID = msgs[0].RecvID
}
if notificationErr := m.notificationSender.NotificationWithSesstionType(ctx, req.UserID, recvID, constant.MsgRevokeNotification, msgs[0].SessionType, &tips); notificationErr != nil {
if err := m.notificationSender.NotificationWithSesstionType(ctx, req.UserID, recvID, constant.MsgRevokeNotification, msgs[0].SessionType, &tips); err != nil {
return nil, err
}
if err = CallbackAfterRevokeMsg(ctx, req); err != nil {

@ -66,7 +66,7 @@ func (m *msgServer) sendMsgSuperGroupChat(
return nil, err
}
if modifyErr := callbackMsgModify(ctx, req); modifyErr != nil {
if err := callbackMsgModify(ctx, req); err != nil {
return nil, err
}
err = m.MsgDatabase.MsgToMQ(ctx, utils.GenConversationUniqueKeyForGroup(req.MsgData.GroupID), req.MsgData)
@ -144,7 +144,7 @@ func (m *msgServer) sendMsgNotification(
}
func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *pbmsg.SendMsgReq) (resp *pbmsg.SendMsgResp, err error) {
if verificationErr := m.messageVerification(ctx, req); verificationErr != nil {
if err := m.messageVerification(ctx, req); err != nil {
return nil, err
}
isSend := true
@ -169,10 +169,10 @@ func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *pbmsg.SendMsgReq
return nil, err
}
if modifyErr := callbackMsgModify(ctx, req); modifyErr != nil {
if err := callbackMsgModify(ctx, req); err != nil {
return nil, err
}
if mqErr := m.MsgDatabase.MsgToMQ(ctx, utils.GenConversationUniqueKeyForSingle(req.MsgData.SendID, req.MsgData.RecvID), req.MsgData); mqErr != nil {
if err := m.MsgDatabase.MsgToMQ(ctx, utils.GenConversationUniqueKeyForSingle(req.MsgData.SendID, req.MsgData.RecvID), req.MsgData); err != nil {
prommetrics.SingleChatMsgProcessFailedCounter.Inc()
return nil, err
}

@ -70,7 +70,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
if err != nil {
return err
}
if indexErr := mongo.CreateMsgIndex(); indexErr != nil {
if err := mongo.CreateMsgIndex(); err != nil {
return err
}
cacheModel := cache.NewMsgCacheModel(rdb)

@ -75,7 +75,7 @@ func (t *thirdServer) InitiateMultipartUpload(ctx context.Context, req *third.In
Group: req.Cause,
CreateTime: time.Now(),
}
if setObjectErr := t.s3dataBase.SetObject(ctx, obj); setObjectErr != nil {
if err := t.s3dataBase.SetObject(ctx, obj); err != nil {
return nil, err
}
return &third.InitiateMultipartUploadResp{
@ -257,10 +257,10 @@ func (t *thirdServer) CompleteFormData(ctx context.Context, req *third.CompleteF
return nil, errs.ErrArgs.Wrap("invalid id " + err.Error())
}
var mate FormDataMate
if unmarshalErr := json.Unmarshal(data, &mate); unmarshalErr != nil {
if err := json.Unmarshal(data, &mate); err != nil {
return nil, errs.ErrArgs.Wrap("invalid id " + err.Error())
}
if uploadErr := checkUploadName(ctx, mate.Name); uploadErr != nil {
if err := checkUploadName(ctx, mate.Name); err != nil {
return nil, err
}
info, err := t.s3dataBase.StatObject(ctx, mate.Key)

@ -56,7 +56,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
if apiURL == "" {
return fmt.Errorf("api url is empty")
}
if _, parseErr := url.Parse(config.Config.Object.ApiURL); parseErr != nil {
if _, err := url.Parse(config.Config.Object.ApiURL); err != nil {
return err
}
if apiURL[len(apiURL)-1] != '/' {

@ -123,11 +123,11 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbuser.UpdateUserI
if err != nil {
return nil, err
}
if callbackErr := CallbackBeforeUpdateUserInfo(ctx, req); callbackErr != nil {
if err := CallbackBeforeUpdateUserInfo(ctx, req); err != nil {
return nil, err
}
data := convert.UserPb2DBMap(req.UserInfo)
if updateErr := s.UpdateByMap(ctx, req.UserInfo.UserID, data); updateErr != nil {
if err := s.UpdateByMap(ctx, req.UserInfo.UserID, data); err != nil {
return nil, err
}
_ = s.friendNotificationSender.UserInfoUpdatedNotification(ctx, req.UserInfo.UserID)

Loading…
Cancel
Save