mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-27 20:30:40 +08:00
Error code standardization
This commit is contained in:
parent
a5a1cbb077
commit
6658566144
@ -4,7 +4,7 @@ import (
|
|||||||
"Open_IM/internal/common/check"
|
"Open_IM/internal/common/check"
|
||||||
"Open_IM/internal/common/convert"
|
"Open_IM/internal/common/convert"
|
||||||
chat "Open_IM/internal/rpc/msg"
|
chat "Open_IM/internal/rpc/msg"
|
||||||
"Open_IM/pkg/common/db/relation"
|
"Open_IM/pkg/common/db/table"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/pkg/common/tracelog"
|
"Open_IM/pkg/common/tracelog"
|
||||||
pbFriend "Open_IM/pkg/proto/friend"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
@ -20,15 +20,11 @@ func (s *friendServer) GetBlacks(ctx context.Context, req *pbFriend.GetBlacksReq
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
blackIDList := make([]string, 0, len(blacks))
|
resp.Blacks, err = (*convert.DBBlack)(nil).DB2PB(blacks)
|
||||||
for _, black := range blacks {
|
if err != nil {
|
||||||
b, err := convert.NewDBBlack(black).Convert()
|
return nil, err
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
resp.Blacks = append(resp.Blacks, b)
|
|
||||||
blackIDList = append(blackIDList, black.BlockUserID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resp.Total = int32(total)
|
resp.Total = int32(total)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
@ -49,10 +45,10 @@ func (s *friendServer) RemoveBlack(ctx context.Context, req *pbFriend.RemoveBlac
|
|||||||
if err := check.Access(ctx, req.OwnerUserID); err != nil {
|
if err := check.Access(ctx, req.OwnerUserID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := s.BlackInterface.Delete(ctx, []*relation.Black{{OwnerUserID: req.OwnerUserID, BlockUserID: req.BlackUserID}}); err != nil {
|
if err := s.BlackInterface.Delete(ctx, []*table.BlackModel{{OwnerUserID: req.OwnerUserID, BlockUserID: req.BlackUserID}}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chat.BlackDeletedNotification(req)
|
chat.BlackDeletedNotification(ctx, req)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,10 +57,10 @@ func (s *friendServer) AddBlack(ctx context.Context, req *pbFriend.AddBlackReq)
|
|||||||
if err := token_verify.CheckAccessV3(ctx, req.OwnerUserID); err != nil {
|
if err := token_verify.CheckAccessV3(ctx, req.OwnerUserID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
black := relation.Black{OwnerUserID: req.OwnerUserID, BlockUserID: req.BlackUserID, OperatorUserID: tracelog.GetOpUserID(ctx)}
|
black := table.BlackModel{OwnerUserID: req.OwnerUserID, BlockUserID: req.BlackUserID, OperatorUserID: tracelog.GetOpUserID(ctx)}
|
||||||
if err := s.BlackInterface.Create(ctx, []*relation.Black{&black}); err != nil {
|
if err := s.BlackInterface.Create(ctx, []*table.BlackModel{&black}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chat.BlackAddedNotification(tracelog.GetOperationID(ctx), req)
|
chat.BlackAddedNotification(ctx, req)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db/controller"
|
"Open_IM/pkg/common/db/controller"
|
||||||
"Open_IM/pkg/common/db/relation"
|
"Open_IM/pkg/common/db/relation"
|
||||||
|
"Open_IM/pkg/common/db/table"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
promePkg "Open_IM/pkg/common/prometheus"
|
promePkg "Open_IM/pkg/common/prometheus"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
@ -197,7 +198,7 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserI
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
err = s.Update(ctx, []*relation.User{user})
|
err = s.Update(ctx, []*table.UserModel{user})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -213,11 +214,11 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserI
|
|||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
for _, v := range rpcResp.FriendsInfo {
|
for _, v := range rpcResp.FriendsInfo {
|
||||||
chat.FriendInfoUpdatedNotification(tracelog.GetOperationID(ctx), req.UserInfo.UserID, v.FriendUser.UserID, tracelog.GetOpUserID(ctx))
|
chat.FriendInfoUpdatedNotification(ctx, req.UserInfo.UserID, v.FriendUser.UserID, tracelog.GetOpUserID(ctx))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
chat.UserInfoUpdatedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.UserInfo.UserID)
|
chat.UserInfoUpdatedNotification(ctx, tracelog.GetOpUserID(ctx), req.UserInfo.UserID)
|
||||||
if req.UserInfo.FaceURL != "" {
|
if req.UserInfo.FaceURL != "" {
|
||||||
s.SyncJoinedGroupMemberFaceURL(ctx, req.UserInfo.UserID, req.UserInfo.FaceURL, tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx))
|
s.SyncJoinedGroupMemberFaceURL(ctx, req.UserInfo.UserID, req.UserInfo.FaceURL, tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx))
|
||||||
}
|
}
|
||||||
@ -235,13 +236,13 @@ func (s *userServer) SetGlobalRecvMessageOpt(ctx context.Context, req *pbUser.Se
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chat.UserInfoUpdatedNotification(tracelog.GetOperationID(ctx), req.UserID, req.UserID)
|
chat.UserInfoUpdatedNotification(ctx, req.UserID, req.UserID)
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) AccountCheck(ctx context.Context, req *pbUser.AccountCheckReq) (*pbUser.AccountCheckResp, error) {
|
func (s *userServer) AccountCheck(ctx context.Context, req *pbUser.AccountCheckReq) (*pbUser.AccountCheckResp, error) {
|
||||||
resp := pbUser.AccountCheckResp{}
|
resp := pbUser.AccountCheckResp{}
|
||||||
err := token_verify.CheckManagerUserID(ctx, tracelog.GetOpUserID(ctx))
|
err := token_verify.CheckAdmin(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/db/relation"
|
"Open_IM/pkg/common/db/table"
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
@ -9,11 +9,11 @@ import (
|
|||||||
|
|
||||||
type BlackInterface interface {
|
type BlackInterface interface {
|
||||||
// Create 增加黑名单
|
// Create 增加黑名单
|
||||||
Create(ctx context.Context, blacks []*relation.Black) (err error)
|
Create(ctx context.Context, blacks []*table.BlackModel) (err error)
|
||||||
// Delete 删除黑名单
|
// Delete 删除黑名单
|
||||||
Delete(ctx context.Context, blacks []*relation.Black) (err error)
|
Delete(ctx context.Context, blacks []*table.BlackModel) (err error)
|
||||||
// FindOwnerBlacks 获取黑名单列表
|
// FindOwnerBlacks 获取黑名单列表
|
||||||
FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*relation.Black, total int64, err error)
|
FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*table.BlackModel, total int64, err error)
|
||||||
// CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true)
|
// CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true)
|
||||||
CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Blacks bool, inUser2Blacks bool, err error)
|
CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Blacks bool, inUser2Blacks bool, err error)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user