Sha256: 19093416515452e7d56b4eab3a1a4234a80919a919c0f12cd0165e87eba28c9f
Contents?: true
Size: 1.32 KB
Versions: 8
Compression:
Stored size: 1.32 KB
Contents
# A generic job for sending events to a user and their followers. # # This class does not implement a usable action, so it must be implemented in a child class # class EventJob < ActiveJob::Base include Rails.application.routes.url_helpers include ActionView::Helpers include ActionView::Helpers::DateHelper include Hydra::AccessControlsEnforcement include SufiaHelper queue_as :event attr_reader :depositor # @param [User] depositor the user to create the event for def perform(depositor) @depositor = depositor # Log the event to the depositor's profile stream log_user_event(depositor) # Fan out the event to all followers who have access log_to_followers(depositor) end # override to provide your specific action for the event you are logging # @abstract def action raise(NotImplementedError, "#action should be implemented by an child class of EventJob") end # create an event with an action and a timestamp for the user def event @event ||= Sufia::Event.create(action, Time.current.to_i) end # log the event to the users event stream def log_user_event(depositor) depositor.log_event(event) end # log the event to the users followers def log_to_followers(depositor) depositor.followers.each do |follower| follower.log_event(event) end end end
Version data entries
8 entries across 8 versions & 1 rubygems