2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-03 08:12:19 +08:00
|
|
|
module Jobs
|
|
|
|
|
2019-10-02 12:01:53 +08:00
|
|
|
class ClosePoll < ::Jobs::Base
|
2018-05-03 08:12:19 +08:00
|
|
|
|
|
|
|
def execute(args)
|
2018-12-13 16:39:36 +08:00
|
|
|
%i{
|
|
|
|
post_id
|
|
|
|
poll_name
|
|
|
|
}.each do |key|
|
|
|
|
raise Discourse::InvalidParameters.new(key) if args[key].blank?
|
|
|
|
end
|
|
|
|
|
|
|
|
DiscoursePoll::Poll.toggle_status(
|
2021-10-05 16:38:49 +08:00
|
|
|
Discourse.system_user,
|
2018-12-13 16:39:36 +08:00
|
|
|
args[:post_id],
|
|
|
|
args[:poll_name],
|
|
|
|
"closed",
|
2018-12-17 22:28:57 +08:00
|
|
|
false
|
2018-12-13 16:39:36 +08:00
|
|
|
)
|
2018-05-03 08:12:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|