diff --git a/internal/api/msg.go b/internal/api/msg.go index c443ccac0..2666e57a9 100644 --- a/internal/api/msg.go +++ b/internal/api/msg.go @@ -6,6 +6,7 @@ import ( "github.com/OpenIMSDK/Open-IM-Server/pkg/apistruct" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify" "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry" "github.com/OpenIMSDK/Open-IM-Server/pkg/errs" "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg" @@ -169,11 +170,10 @@ func (m *MessageApi) SendMessage(c *gin.Context) { apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap()) return } - // todo - //if !tokenverify.IsAppManagerUid(c) { - // apiresp.GinError(c, errs.ErrNoPermission.Wrap("only app manager can send message")) - // return - //} + if !tokenverify.IsAppManagerUid(c) { + apiresp.GinError(c, errs.ErrNoPermission.Wrap("only app manager can send message")) + return + } var data interface{} switch params.ContentType { diff --git a/pkg/common/db/relation/user_model.go b/pkg/common/db/relation/user_model.go index da62ffff8..66bcb3f7d 100644 --- a/pkg/common/db/relation/user_model.go +++ b/pkg/common/db/relation/user_model.go @@ -25,7 +25,7 @@ func (u *UserGorm) Create(ctx context.Context, users []*relation.UserModel) (err // 更新用户信息 零值 func (u *UserGorm) UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error) { - return utils.Wrap(u.db(ctx).Where("user_id = ?", userID).Updates(args).Error, "") + return utils.Wrap(u.db(ctx).Model(&relation.UserModel{}).Where("user_id = ?", userID).Updates(args).Error, "") } // 更新多个用户信息 非零值