Class: Curate::ContentDepositEventJob

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers, ActionView::Helpers::DateHelper, Hydra::AccessControlsEnforcement
Defined in:
lib/curate/jobs/content_deposit_event_job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(generic_file_id, depositor_id) ⇒ ContentDepositEventJob

Returns a new instance of ContentDepositEventJob.



14
15
16
17
# File 'lib/curate/jobs/content_deposit_event_job.rb', line 14

def initialize(generic_file_id, depositor_id)
  self.generic_file_id = generic_file_id
  self.depositor_id = depositor_id
end

Instance Attribute Details

#depositor_idObject

Returns the value of attribute depositor_id.



12
13
14
# File 'lib/curate/jobs/content_deposit_event_job.rb', line 12

def depositor_id
  @depositor_id
end

#generic_file_idObject

Returns the value of attribute generic_file_id.



12
13
14
# File 'lib/curate/jobs/content_deposit_event_job.rb', line 12

def generic_file_id
  @generic_file_id
end

Instance Method Details

#queue_nameObject



8
9
10
# File 'lib/curate/jobs/content_deposit_event_job.rb', line 8

def queue_name
  :event
end

#runObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/curate/jobs/content_deposit_event_job.rb', line 19

def run
  gf = GenericFile.find(generic_file_id)
  action = "User #{depositor_id} has deposited #{gf.title} (#{gf.noid})"
  timestamp = Time.now.to_i
  depositor = ::User.find_by_user_key(depositor_id)
  
  event = depositor.create_event(action, timestamp)
  
  depositor.log_profile_event(event)
  
  gf.log_event(event)
  
  depositor.followers.select { |user| user.can? :read, gf }.each do |follower|
    follower.log_event(event)
  end
end