From f971a8ba5441552533cdd9fe8df3721056d3faf1 Mon Sep 17 00:00:00 2001 From: luhaoling <2198702716@qq.com> Date: Wed, 3 Jan 2024 17:01:57 +0800 Subject: [PATCH] fix: fix the error --- internal/rpc/user/user.go | 2 +- pkg/authverify/token.go | 8 ++++++-- pkg/common/db/controller/user.go | 4 ++-- pkg/common/db/mgo/user.go | 2 +- pkg/common/db/table/relation/user.go | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index 8270c822e..51403d631 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -515,7 +515,7 @@ func (s *userServer) SearchNotificationAccount(ctx context.Context, req *pbuser. return resp, nil } - users, err := s.UserDatabase.FindNotification(ctx, string(constant.AppNotificationAdmin)) + users, err := s.UserDatabase.FindNotification(ctx, constant.AppNotificationAdmin) if err != nil { return nil, err } diff --git a/pkg/authverify/token.go b/pkg/authverify/token.go index 2cca5af7f..cc816a47f 100644 --- a/pkg/authverify/token.go +++ b/pkg/authverify/token.go @@ -38,6 +38,9 @@ func CheckAccessV3(ctx context.Context, ownerUserID string) (err error) { if utils.IsContain(opUserID, config.Config.Manager.UserID) { return nil } + if utils.IsContain(opUserID, config.Config.Manager.UserID) { + return nil + } if opUserID == ownerUserID { return nil } @@ -45,7 +48,7 @@ func CheckAccessV3(ctx context.Context, ownerUserID string) (err error) { } func IsAppManagerUid(ctx context.Context) bool { - return utils.IsContain(mcontext.GetOpUserID(ctx), config.Config.Manager.UserID) + return utils.IsContain(mcontext.GetOpUserID(ctx), config.Config.Manager.UserID) || utils.IsContain(mcontext.GetOpUserID(ctx), config.Config.IMAdmin.UserID) } func CheckAdmin(ctx context.Context) error { @@ -72,7 +75,8 @@ func ParseRedisInterfaceToken(redisToken any) (*tokenverify.Claims, error) { } func IsManagerUserID(opUserID string) bool { - return utils.IsContain(opUserID, config.Config.Manager.UserID) + return utils.IsContain(opUserID, config.Config.Manager.UserID) || utils.IsContain(opUserID, config.Config.IMAdmin.UserID) + } func WsVerifyToken(token, userID string, platformID int) error { diff --git a/pkg/common/db/controller/user.go b/pkg/common/db/controller/user.go index 4790a0c52..a109b81ef 100644 --- a/pkg/common/db/controller/user.go +++ b/pkg/common/db/controller/user.go @@ -41,7 +41,7 @@ type UserDatabase interface { // Find userInfo By Nickname FindByNickname(ctx context.Context, nickname string) (users []*relation.UserModel, err error) // Find notificationAccounts - FindNotification(ctx context.Context, level string) (users []*relation.UserModel, err error) + FindNotification(ctx context.Context, level int64) (users []*relation.UserModel, err error) // Create Insert multiple external guarantees that the userID is not repeated and does not exist in the db Create(ctx context.Context, users []*relation.UserModel) (err error) // Update update (non-zero value) external guarantee userID exists @@ -143,7 +143,7 @@ func (u *userDatabase) FindByNickname(ctx context.Context, nickname string) (use } // Find notificationAccouts -func (u *userDatabase) FindNotification(ctx context.Context, level string) (users []*relation.UserModel, err error) { +func (u *userDatabase) FindNotification(ctx context.Context, level int64) (users []*relation.UserModel, err error) { return u.userDB.TakeNotification(ctx, level) } diff --git a/pkg/common/db/mgo/user.go b/pkg/common/db/mgo/user.go index 770b0208f..27ca264dd 100644 --- a/pkg/common/db/mgo/user.go +++ b/pkg/common/db/mgo/user.go @@ -65,7 +65,7 @@ func (u *UserMgo) Take(ctx context.Context, userID string) (user *relation.UserM return mgoutil.FindOne[*relation.UserModel](ctx, u.coll, bson.M{"user_id": userID}) } -func (u *UserMgo) TakeNotification(ctx context.Context, level string) (user []*relation.UserModel, err error) { +func (u *UserMgo) TakeNotification(ctx context.Context, level int64) (user []*relation.UserModel, err error) { return mgoutil.Find[*relation.UserModel](ctx, u.coll, bson.M{"app_manger_level": level}) } diff --git a/pkg/common/db/table/relation/user.go b/pkg/common/db/table/relation/user.go index 20ed219dd..fc116adc2 100644 --- a/pkg/common/db/table/relation/user.go +++ b/pkg/common/db/table/relation/user.go @@ -53,7 +53,7 @@ type UserModelInterface interface { UpdateByMap(ctx context.Context, userID string, args map[string]any) (err error) Find(ctx context.Context, userIDs []string) (users []*UserModel, err error) Take(ctx context.Context, userID string) (user *UserModel, err error) - TakeNotification(ctx context.Context, level string) (user []*UserModel, err error) + TakeNotification(ctx context.Context, level int64) (user []*UserModel, err error) TakeByNickname(ctx context.Context, nickname string) (user []*UserModel, err error) Page(ctx context.Context, pagination pagination.Pagination) (count int64, users []*UserModel, err error) Exist(ctx context.Context, userID string) (exist bool, err error)