diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-29 21:08:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-29 21:08:47 +0300 |
commit | 6b9d3a4e8351e662c4586b24bb152de78ae9e3bf (patch) | |
tree | 883e9db60c047c54418fc1d2b1c5517f97e0f185 /app/workers/mail_scheduler | |
parent | 23288f62da73fb0e30d8e7ce306665e8fda1b932 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/workers/mail_scheduler')
-rw-r--r-- | app/workers/mail_scheduler/notification_service_worker.rb | 41 |
1 files changed, 9 insertions, 32 deletions
diff --git a/app/workers/mail_scheduler/notification_service_worker.rb b/app/workers/mail_scheduler/notification_service_worker.rb index 4130ce25878..ec659e39b24 100644 --- a/app/workers/mail_scheduler/notification_service_worker.rb +++ b/app/workers/mail_scheduler/notification_service_worker.rb @@ -26,49 +26,26 @@ module MailScheduler end def self.perform_async(*args) - super(*Arguments.serialize(args)) + super(*ActiveJob::Arguments.serialize(args)) end private - # If an argument is in the ActiveJob::Arguments::TYPE_WHITELIST list, + # This is copied over from https://github.com/rails/rails/blob/v6.0.1/activejob/lib/active_job/arguments.rb#L50 + # because it is declared as a private constant + PERMITTED_TYPES = [NilClass, String, Integer, Float, BigDecimal, TrueClass, FalseClass].freeze + + private_constant :PERMITTED_TYPES + + # If an argument is in the PERMITTED_TYPES list, # it means the argument cannot be deserialized. # Which means there's something wrong with our code. def check_arguments!(args) args.each do |arg| - if arg.class.in?(ActiveJob::Arguments::TYPE_WHITELIST) + if arg.class.in?(PERMITTED_TYPES) raise(ArgumentError, "Argument `#{arg}` cannot be deserialized because of its type") end end end - - # Permit ActionController::Parameters for serializable Hash - # - # Port of - # https://github.com/rails/rails/commit/945fdd76925c9f615bf016717c4c8db2b2955357#diff-fc90ec41ef75be8b2259526fe1a8b663 - module Arguments - include ActiveJob::Arguments - extend self - - private - - def serialize_argument(argument) - case argument - when -> (arg) { arg.respond_to?(:permitted?) } - serialize_hash(argument.to_h).tap do |result| - result[WITH_INDIFFERENT_ACCESS_KEY] = serialize_argument(true) - end - else - super - end - end - end - - # Make sure we remove this patch starting with Rails 6.0. - if Rails.version.start_with?('6.0') - raise <<~MSG - Please remove the patch `Arguments` module and use `ActiveJob::Arguments` again. - MSG - end end end |