Fix autoload issues in subscriber

pull/16171/head
Alberto Miedes Garcés 4 years ago
parent e345873447
commit af267cc08f

@ -75,6 +75,7 @@ sudo make install
- Added dynamic meta title and canonical link to improve SEO in public pages for the Spatial Data Catalog [#16157](https://github.com/CartoDB/cartodb/pull/16157)
- Fixed error that added multiple canonical links in the Spatial Data Catalog [#16160](https://github.com/CartoDB/cartodb/pull/16160)
- Modify deprecation warning for DO analysis in builder [#16163](https://github.com/CartoDB/cartodb/pull/16163)
- Fix autoload issues in subscriber [#16171](https://github.com/CartoDB/cartodb/pull/16171)
4.44.0 (2020-11-20)
-------------------

@ -1,24 +1,10 @@
require 'securerandom'
require './lib/api_key_grants_validator'
require_dependency 'carto/errors'
require_dependency 'carto/helpers/auth_token_generator'
require_dependency 'carto/oauth_provider/scopes/scopes'
require_dependency 'carto/api_key_permissions'
class ApiKeyGrantsValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
return record.errors[attribute] = ['grants has to be an array'] unless value&.is_a?(Array)
record.errors[attribute] << 'only one apis section is allowed' unless value.count { |v| v[:type] == 'apis' } == 1
max_one_sections = ['database', 'dataservices', 'user', 'data-observatory']
max_one_sections.each do |section|
if value.count { |v| v[:type] == section } > 1
record.errors[attribute] << "only one #{section} section is allowed"
end
end
end
end
module Carto
class ApiKey < ActiveRecord::Base

@ -0,0 +1,16 @@
class ApiKeyGrantsValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
return record.errors[attribute] = ['grants has to be an array'] unless value.is_a?(Array)
record.errors[attribute] << 'only one apis section is allowed' unless value.count { |v| v[:type] == 'apis' } == 1
max_one_sections = ['database', 'dataservices', 'user', 'data-observatory']
max_one_sections.each do |section|
if value.count { |v| v[:type] == section } > 1
record.errors[attribute] << "only one #{section} section is allowed"
end
end
end
end

@ -8,6 +8,10 @@ end
namespace :message_broker do
desc 'Consume messages from subscription "central_cartodb_commands"'
task cartodb_subscribers: [:environment] do |_task, _args|
# Eager load Ruby classes, as Rake does not do it by default
# https://github.com/rails/rails/issues/28358
Rails.application.eager_load!
$stdout.sync = true
logger = Carto::Common::Logger.new($stdout)
pid_file = ENV['PIDFILE'] || Rails.root.join('tmp/pids/cartodb_subscribers.pid')

Loading…
Cancel
Save