diff options
author | Peter Leitzen <pleitzen@gitlab.com> | 2019-02-05 10:39:14 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-02-05 10:39:14 +0000 |
commit | 8dd3dc182e60224931034a692ec1be06a7d6e3df (patch) | |
tree | d652c281abc907d124a78155d40ce840725a31e9 /app/workers/mail_scheduler | |
parent | 97041bb6c480e94593b1b7ee3102149ad30804dc (diff) | |
download | gitlab-ce-8dd3dc182e60224931034a692ec1be06a7d6e3df.tar.gz |
Make `ActionContorller::Parameters` serializable for sidekiq jobs
Diffstat (limited to 'app/workers/mail_scheduler')
-rw-r--r-- | app/workers/mail_scheduler/notification_service_worker.rb | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/app/workers/mail_scheduler/notification_service_worker.rb b/app/workers/mail_scheduler/notification_service_worker.rb index c8ccaf0c487..421fbf04e28 100644 --- a/app/workers/mail_scheduler/notification_service_worker.rb +++ b/app/workers/mail_scheduler/notification_service_worker.rb @@ -23,7 +23,7 @@ module MailScheduler end def self.perform_async(*args) - super(*ActiveJob::Arguments.serialize(args)) + super(*Arguments.serialize(args)) end private @@ -38,5 +38,34 @@ module MailScheduler 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 |