Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/workers/mail_scheduler/notification_service_worker.rb')
-rw-r--r--app/workers/mail_scheduler/notification_service_worker.rb41
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