2013-05-07 14:25:41 -04:00
|
|
|
module Jobs
|
|
|
|
class CloseTopic < Jobs::Base
|
|
|
|
|
|
|
|
def execute(args)
|
2014-05-06 09:41:59 -04:00
|
|
|
if topic = Topic.find_by(id: args[:topic_id])
|
|
|
|
closer = User.find_by(id: args[:user_id])
|
2015-03-27 18:31:04 -04:00
|
|
|
guardian = Guardian.new(closer)
|
|
|
|
unless guardian.can_close?(topic)
|
|
|
|
closer = Discourse.system_user
|
|
|
|
end
|
2013-11-10 18:52:44 -05:00
|
|
|
topic.auto_close(closer)
|
2013-05-07 14:25:41 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|