6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/jobs/decidim/debates/settings_change_job.rb', line 6
def perform(feature_id, previous_settings, current_settings)
return if unchanged?(previous_settings, current_settings)
feature = Decidim::Feature.find(feature_id)
if debate_creation_enabled?(previous_settings, current_settings)
event = "decidim.events.debates.creation_enabled"
event_class = Decidim::Debates::CreationEnabledEvent
elsif debate_creation_disabled?(previous_settings, current_settings)
event = "decidim.events.debates.creation_disabled"
event_class = Decidim::Debates::CreationDisabledEvent
end
Decidim::EventsManager.publish(
event: event,
event_class: event_class,
resource: feature,
recipient_ids: feature.participatory_space.followers.pluck(:id)
)
end
|