Sha256: a199348ce7a8b0d7a234cb8a294b0def58bd5dfa003fda8e9c455e60cd8b47d9

Contents?: true

Size: 637 Bytes

Versions: 7

Compression:

Stored size: 637 Bytes

Contents

# frozen_string_literal: true

module Hyrax
  module Listeners
    ##
    # Listens for deposit events, and checks for proxy situations. When a user
    # deposits an item `on_behalf_of` another, ensures transfer is handled.
    class ProxyDepositListener
      ##
      # @param event [Dry::Event]
      def on_object_deposited(event)
        return if event[:object].try(:on_behalf_of).blank? ||
                  (event[:object].on_behalf_of == event[:object].depositor)

        ContentDepositorChangeEventJob
          .perform_later(event[:object], ::User.find_by_user_key(event[:object].on_behalf_of))
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hyrax-3.2.0 app/services/hyrax/listeners/proxy_deposit_listener.rb
hyrax-3.1.0 app/services/hyrax/listeners/proxy_deposit_listener.rb
hyrax-3.0.2 app/services/hyrax/listeners/proxy_deposit_listener.rb
hyrax-3.0.1 app/services/hyrax/listeners/proxy_deposit_listener.rb
hyrax-3.0.0 app/services/hyrax/listeners/proxy_deposit_listener.rb
hyrax-3.0.0.pre.rc4 app/services/hyrax/listeners/proxy_deposit_listener.rb
hyrax-3.0.0.pre.rc3 app/services/hyrax/listeners/proxy_deposit_listener.rb