6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/jobs/decidim/surveys/settings_change_job.rb', line 6
def perform(component_id, previous_settings, current_settings)
return if unchanged?(previous_settings, current_settings)
component = Decidim::Component.find(component_id)
if survey_opened?(previous_settings, current_settings)
event = "decidim.events.surveys.survey_opened"
event_class = Decidim::Surveys::OpenedSurveyEvent
elsif survey_closed?(previous_settings, current_settings)
event = "decidim.events.surveys.survey_closed"
event_class = Decidim::Surveys::ClosedSurveyEvent
end
return unless event && event_class
Decidim::EventsManager.publish(
event:,
event_class:,
resource: component,
followers: component.participatory_space.followers
)
end
|