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