mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-31 06:48:25 +08:00
fix: fix tools erros code
This commit is contained in:
parent
0327e33ee7
commit
10bb10be9e
@ -206,7 +206,7 @@ func (m *MessageApi) SendMessage(c *gin.Context) {
|
|||||||
// Check if the user has the app manager role.
|
// Check if the user has the app manager role.
|
||||||
if !authverify.IsAppManagerUid(c, m.manager, m.imAdmin) {
|
if !authverify.IsAppManagerUid(c, m.manager, m.imAdmin) {
|
||||||
// Respond with a permission error if the user is not an app manager.
|
// Respond with a permission error if the user is not an app manager.
|
||||||
apiresp.GinError(c, errs.ErrNoPermission.Wrap("only app manager can send message"))
|
apiresp.GinError(c, errs.ErrNoPermission.WrapMsg("only app manager can send message"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +263,7 @@ func (m *MessageApi) SendBusinessNotification(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !authverify.IsAppManagerUid(c, m.manager, m.imAdmin) {
|
if !authverify.IsAppManagerUid(c, m.manager, m.imAdmin) {
|
||||||
apiresp.GinError(c, errs.ErrNoPermission.Wrap("only app manager can send message"))
|
apiresp.GinError(c, errs.ErrNoPermission.WrapMsg("only app manager can send message"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sendMsgReq := msg.SendMsgReq{
|
sendMsgReq := msg.SendMsgReq{
|
||||||
@ -307,7 +307,7 @@ func (m *MessageApi) BatchSendMsg(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
log.ZInfo(c, "BatchSendMsg", "req", req)
|
log.ZInfo(c, "BatchSendMsg", "req", req)
|
||||||
if err := authverify.CheckAdmin(c, m.manager, m.imAdmin); err != nil {
|
if err := authverify.CheckAdmin(c, m.manager, m.imAdmin); err != nil {
|
||||||
apiresp.GinError(c, errs.ErrNoPermission.Wrap("only app manager can send message"))
|
apiresp.GinError(c, errs.ErrNoPermission.WrapMsg("only app manager can send message"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -91,7 +91,7 @@ func (s *Server) GetUsersOnlineStatus(
|
|||||||
req *msggateway.GetUsersOnlineStatusReq,
|
req *msggateway.GetUsersOnlineStatusReq,
|
||||||
) (*msggateway.GetUsersOnlineStatusResp, error) {
|
) (*msggateway.GetUsersOnlineStatusResp, error) {
|
||||||
if !authverify.IsAppManagerUid(ctx, &s.config.Manager, &s.config.IMAdmin) {
|
if !authverify.IsAppManagerUid(ctx, &s.config.Manager, &s.config.IMAdmin) {
|
||||||
return nil, errs.ErrNoPermission.Wrap("only app manager")
|
return nil, errs.ErrNoPermission.WrapMsg("only app manager")
|
||||||
}
|
}
|
||||||
var resp msggateway.GetUsersOnlineStatusResp
|
var resp msggateway.GetUsersOnlineStatusResp
|
||||||
for _, userID := range req.UserIDs {
|
for _, userID := range req.UserIDs {
|
||||||
|
|||||||
@ -64,7 +64,7 @@ func Start(config *config.GlobalConfig, client discoveryregistry.SvcDiscoveryReg
|
|||||||
func (s *authServer) UserToken(ctx context.Context, req *pbauth.UserTokenReq) (*pbauth.UserTokenResp, error) {
|
func (s *authServer) UserToken(ctx context.Context, req *pbauth.UserTokenReq) (*pbauth.UserTokenResp, error) {
|
||||||
resp := pbauth.UserTokenResp{}
|
resp := pbauth.UserTokenResp{}
|
||||||
if req.Secret != s.config.Secret {
|
if req.Secret != s.config.Secret {
|
||||||
return nil, errs.ErrNoPermission.Wrap("secret invalid")
|
return nil, errs.ErrNoPermission.WrapMsg("secret invalid")
|
||||||
}
|
}
|
||||||
if _, err := s.userRpcClient.GetUserInfo(ctx, req.UserID); err != nil {
|
if _, err := s.userRpcClient.GetUserInfo(ctx, req.UserID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -86,7 +86,7 @@ func (s *authServer) GetUserToken(ctx context.Context, req *pbauth.GetUserTokenR
|
|||||||
resp := pbauth.GetUserTokenResp{}
|
resp := pbauth.GetUserTokenResp{}
|
||||||
|
|
||||||
if authverify.IsManagerUserID(req.UserID, &s.config.Manager, &s.config.IMAdmin) {
|
if authverify.IsManagerUserID(req.UserID, &s.config.Manager, &s.config.IMAdmin) {
|
||||||
return nil, errs.ErrNoPermission.Wrap("don't get Admin token")
|
return nil, errs.ErrNoPermission.WrapMsg("don't get Admin token")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := s.userRpcClient.GetUserInfo(ctx, req.UserID); err != nil {
|
if _, err := s.userRpcClient.GetUserInfo(ctx, req.UserID); err != nil {
|
||||||
|
|||||||
@ -139,7 +139,7 @@ func (s *groupServer) CheckGroupAdmin(ctx context.Context, groupID string) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !(groupMember.RoleLevel == constant.GroupOwner || groupMember.RoleLevel == constant.GroupAdmin) {
|
if !(groupMember.RoleLevel == constant.GroupOwner || groupMember.RoleLevel == constant.GroupAdmin) {
|
||||||
return errs.ErrNoPermission.Wrap("no group owner or admin")
|
return errs.ErrNoPermission.WrapMsg("no group owner or admin")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -572,22 +572,22 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbgroup.KickGrou
|
|||||||
for _, userID := range req.KickedUserIDs {
|
for _, userID := range req.KickedUserIDs {
|
||||||
member, ok := memberMap[userID]
|
member, ok := memberMap[userID]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errs.ErrUserIDNotFound.Wrap(userID)
|
return nil, errs.ErrUserIDNotFound.WrapMsg(userID)
|
||||||
}
|
}
|
||||||
if !isAppManagerUid {
|
if !isAppManagerUid {
|
||||||
if opMember == nil {
|
if opMember == nil {
|
||||||
return nil, errs.ErrNoPermission.Wrap("opUserID no in group")
|
return nil, errs.ErrNoPermission.WrapMsg("opUserID no in group")
|
||||||
}
|
}
|
||||||
switch opMember.RoleLevel {
|
switch opMember.RoleLevel {
|
||||||
case constant.GroupOwner:
|
case constant.GroupOwner:
|
||||||
case constant.GroupAdmin:
|
case constant.GroupAdmin:
|
||||||
if member.RoleLevel == constant.GroupOwner || member.RoleLevel == constant.GroupAdmin {
|
if member.RoleLevel == constant.GroupOwner || member.RoleLevel == constant.GroupAdmin {
|
||||||
return nil, errs.ErrNoPermission.Wrap("group admins cannot remove the group owner and other admins")
|
return nil, errs.ErrNoPermission.WrapMsg("group admins cannot remove the group owner and other admins")
|
||||||
}
|
}
|
||||||
case constant.GroupOrdinaryUsers:
|
case constant.GroupOrdinaryUsers:
|
||||||
return nil, errs.ErrNoPermission.Wrap("opUserID no permission")
|
return nil, errs.ErrNoPermission.WrapMsg("opUserID no permission")
|
||||||
default:
|
default:
|
||||||
return nil, errs.ErrNoPermission.Wrap("opUserID roleLevel unknown")
|
return nil, errs.ErrNoPermission.WrapMsg("opUserID roleLevel unknown")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -706,7 +706,7 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbgroup.
|
|||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
if ids := utils.Single(utils.Keys(groupMap), groupIDs); len(ids) > 0 {
|
if ids := utils.Single(utils.Keys(groupMap), groupIDs); len(ids) > 0 {
|
||||||
return nil, errs.ErrGroupIDNotFound.Wrap(strings.Join(ids, ","))
|
return nil, errs.ErrGroupIDNotFound.WrapMsg(strings.Join(ids, ","))
|
||||||
}
|
}
|
||||||
groupMemberNumMap, err := s.db.MapGroupMemberNum(ctx, groupIDs)
|
groupMemberNumMap, err := s.db.MapGroupMemberNum(ctx, groupIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -776,7 +776,7 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbgroup
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !(groupMember.RoleLevel == constant.GroupOwner || groupMember.RoleLevel == constant.GroupAdmin) {
|
if !(groupMember.RoleLevel == constant.GroupOwner || groupMember.RoleLevel == constant.GroupAdmin) {
|
||||||
return nil, errs.ErrNoPermission.Wrap("no group owner or admin")
|
return nil, errs.ErrNoPermission.WrapMsg("no group owner or admin")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
group, err := s.db.TakeGroup(ctx, req.GroupID)
|
group, err := s.db.TakeGroup(ctx, req.GroupID)
|
||||||
@ -788,7 +788,7 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbgroup
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if groupRequest.HandleResult != 0 {
|
if groupRequest.HandleResult != 0 {
|
||||||
return nil, errs.ErrGroupRequestHandled.Wrap("group request already processed")
|
return nil, errs.ErrGroupRequestHandled.WrapMsg("group request already processed")
|
||||||
}
|
}
|
||||||
var inGroup bool
|
var inGroup bool
|
||||||
if _, err := s.db.TakeGroupMember(ctx, req.GroupID, req.FromUserID); err == nil {
|
if _, err := s.db.TakeGroupMember(ctx, req.GroupID, req.FromUserID); err == nil {
|
||||||
|
|||||||
@ -80,10 +80,10 @@ func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.
|
|||||||
case constant.GroupOwner:
|
case constant.GroupOwner:
|
||||||
case constant.GroupAdmin:
|
case constant.GroupAdmin:
|
||||||
if members[msgs[0].SendID].RoleLevel != constant.GroupOrdinaryUsers {
|
if members[msgs[0].SendID].RoleLevel != constant.GroupOrdinaryUsers {
|
||||||
return nil, errs.ErrNoPermission.Wrap("no permission")
|
return nil, errs.ErrNoPermission.WrapMsg("no permission")
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return nil, errs.ErrNoPermission.Wrap("no permission")
|
return nil, errs.ErrNoPermission.WrapMsg("no permission")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if member := members[req.UserID]; member != nil {
|
if member := members[req.UserID]; member != nil {
|
||||||
|
|||||||
@ -54,7 +54,7 @@ func (t *thirdServer) checkUploadName(ctx context.Context, name string) error {
|
|||||||
}
|
}
|
||||||
opUserID := mcontext.GetOpUserID(ctx)
|
opUserID := mcontext.GetOpUserID(ctx)
|
||||||
if opUserID == "" {
|
if opUserID == "" {
|
||||||
return errs.ErrNoPermission.Wrap("opUserID is empty")
|
return errs.ErrNoPermission.WrapMsg("opUserID is empty")
|
||||||
}
|
}
|
||||||
if !authverify.IsManagerUserID(opUserID, t.config) {
|
if !authverify.IsManagerUserID(opUserID, t.config) {
|
||||||
if !strings.HasPrefix(name, opUserID+"/") {
|
if !strings.HasPrefix(name, opUserID+"/") {
|
||||||
|
|||||||
@ -246,7 +246,7 @@ func (s *userServer) UserRegister(ctx context.Context, req *pbuser.UserRegisterR
|
|||||||
}
|
}
|
||||||
if req.Secret != s.config.Secret {
|
if req.Secret != s.config.Secret {
|
||||||
log.ZDebug(ctx, "UserRegister", s.config.Secret, req.Secret)
|
log.ZDebug(ctx, "UserRegister", s.config.Secret, req.Secret)
|
||||||
return nil, errs.ErrNoPermission.Wrap("secret invalid")
|
return nil, errs.ErrNoPermission.WrapMsg("secret invalid")
|
||||||
}
|
}
|
||||||
if utils.DuplicateAny(req.Users, func(e *sdkws.UserInfo) string { return e.UserID }) {
|
if utils.DuplicateAny(req.Users, func(e *sdkws.UserInfo) string { return e.UserID }) {
|
||||||
return nil, errs.ErrArgs.Wrap("userID repeated")
|
return nil, errs.ErrArgs.Wrap("userID repeated")
|
||||||
@ -649,7 +649,7 @@ func (s *userServer) GetNotificationAccount(ctx context.Context, req *pbuser.Get
|
|||||||
return &pbuser.GetNotificationAccountResp{}, nil
|
return &pbuser.GetNotificationAccountResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, errs.ErrNoPermission.Wrap("notification messages cannot be sent for this ID")
|
return nil, errs.ErrNoPermission.WrapMsg("notification messages cannot be sent for this ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) genUserID() string {
|
func (s *userServer) genUserID() string {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user