Skip to content

Commit

Permalink
Don't store AR objects in Notification options
Browse files Browse the repository at this point in the history
The `:subject`, `:initiator`, and `:cause` attributes are all
`belongs_to` associations on the `Notification` model and should not be
stored in the `:options` yaml column.
  • Loading branch information
agrare committed Nov 20, 2023
1 parent 7f75ccc commit 5c78a88
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions app/models/manageiq/providers/openstack/helper_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ def parse_error_message_excon_http_status(exception)
end

def with_notification(type, options: {})
# We're explicitly serializing objects in the options subject key so we should permit yaml loading those classes
if options[:subject]
ActiveRecord::Base.yaml_column_permitted_classes = ActiveRecord::Base.yaml_column_permitted_classes | [options[:subject].class]
end

# extract success and error options from options
# :success and :error keys respectively
# with all other keys common for both cases
Expand All @@ -77,12 +72,8 @@ def with_notification(type, options: {})
success_options.merge!(options)
error_options.merge!(options)

# copy subject, initiator and cause from options
named_options_keys = [:subject, :initiator, :cause]
named_options = {}
named_options_keys.map do |key|
named_options[key] = options.fetch(key, nil)
end
# extract subject, initiator and cause from options
named_options = options.extract!(:subject, :initiator, :cause)

begin
yield
Expand Down

0 comments on commit 5c78a88

Please sign in to comment.