refactor: Update tenant ID handling across the application
This commit is contained in:
@@ -101,7 +101,7 @@ func (s *modelService) GetModelByID(ctx context.Context, id string) (*types.Mode
|
||||
return nil, errors.New("model ID cannot be empty")
|
||||
}
|
||||
|
||||
tenantID := ctx.Value(types.TenantIDContextKey).(uint)
|
||||
tenantID := ctx.Value(types.TenantIDContextKey).(uint64)
|
||||
|
||||
// Fetch model from repository
|
||||
model, err := s.repo.GetByID(ctx, tenantID, id)
|
||||
@@ -145,7 +145,7 @@ func (s *modelService) GetModelByID(ctx context.Context, id string) (*types.Mode
|
||||
func (s *modelService) ListModels(ctx context.Context) ([]*types.Model, error) {
|
||||
logger.Info(ctx, "Start listing models")
|
||||
|
||||
tenantID := ctx.Value(types.TenantIDContextKey).(uint)
|
||||
tenantID := ctx.Value(types.TenantIDContextKey).(uint64)
|
||||
logger.Infof(ctx, "Listing models for tenant ID: %d", tenantID)
|
||||
|
||||
// List models from repository with no additional filters
|
||||
@@ -167,7 +167,7 @@ func (s *modelService) UpdateModel(ctx context.Context, model *types.Model) erro
|
||||
logger.Infof(ctx, "Updating model ID: %s, name: %s", model.ID, model.Name)
|
||||
|
||||
// Check if the model is builtin - builtin models cannot be updated
|
||||
tenantID := ctx.Value(types.TenantIDContextKey).(uint)
|
||||
tenantID := ctx.Value(types.TenantIDContextKey).(uint64)
|
||||
existingModel, err := s.repo.GetByID(ctx, tenantID, model.ID)
|
||||
if err != nil {
|
||||
logger.ErrorWithFields(ctx, err, map[string]interface{}{
|
||||
@@ -199,7 +199,7 @@ func (s *modelService) DeleteModel(ctx context.Context, id string) error {
|
||||
logger.Info(ctx, "Start deleting model")
|
||||
logger.Infof(ctx, "Deleting model ID: %s", id)
|
||||
|
||||
tenantID := ctx.Value(types.TenantIDContextKey).(uint)
|
||||
tenantID := ctx.Value(types.TenantIDContextKey).(uint64)
|
||||
logger.Infof(ctx, "Tenant ID: %d", tenantID)
|
||||
|
||||
// Check if the model is builtin - builtin models cannot be deleted
|
||||
@@ -308,7 +308,7 @@ func (s *modelService) GetChatModel(ctx context.Context, modelId string) (chat.C
|
||||
return nil, errors.New("model ID cannot be empty")
|
||||
}
|
||||
|
||||
tenantID := ctx.Value(types.TenantIDContextKey).(uint)
|
||||
tenantID := ctx.Value(types.TenantIDContextKey).(uint64)
|
||||
|
||||
// Get the model directly from repository to avoid status checks
|
||||
model, err := s.repo.GetByID(ctx, tenantID, modelId)
|
||||
|
||||
Reference in New Issue
Block a user