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