Class: Decidim::EventPublisherJob

Inherits:
ApplicationJob show all
Defined in:
decidim-core/app/jobs/decidim/event_publisher_job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'decidim-core/app/jobs/decidim/event_publisher_job.rb', line 7

def data
  @data
end

#resourceObject (readonly)

Returns the value of attribute resource.



7
8
9
# File 'decidim-core/app/jobs/decidim/event_publisher_job.rb', line 7

def resource
  @resource
end

Instance Method Details

#perform(event_name, data) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'decidim-core/app/jobs/decidim/event_publisher_job.rb', line 9

def perform(event_name, data)
  @resource = data[:resource]
  @data = data

  return unless data[:force_send] || notifiable?

  if event_type.include?(:email)
    EmailNotificationGeneratorJob.perform_later(
      event_name,
      data[:event_class],
      data[:resource],
      data[:followers],
      data[:affected_users],
      data[:extra]
    )
  end

  return unless event_type.include?(:notification)

  NotificationGeneratorJob.perform_later(
    event_name,
    data[:event_class],
    data[:resource],
    data[:followers],
    data[:affected_users],
    data[:extra]
  )
end