discourse/plugins/poll/jobs/regular/close_poll.rb
Bianca Nenciu 6a143030f8
FEATURE: Allow users to remove their vote (#14459)
They can use the remove vote button or select the same option again for
single choice polls.

This commit refactor the plugin to properly organize code and make it
easier to follow.
2021-10-05 11:38:49 +03:00

27 lines
431 B
Ruby

# frozen_string_literal: true
module Jobs
class ClosePoll < ::Jobs::Base
def execute(args)
%i{
post_id
poll_name
}.each do |key|
raise Discourse::InvalidParameters.new(key) if args[key].blank?
end
DiscoursePoll::Poll.toggle_status(
Discourse.system_user,
args[:post_id],
args[:poll_name],
"closed",
false
)
end
end
end