diff --git a/app/jobs/regular/close_topic.rb b/app/jobs/regular/close_topic.rb index 61a27588cef..0703c971f55 100644 --- a/app/jobs/regular/close_topic.rb +++ b/app/jobs/regular/close_topic.rb @@ -4,6 +4,10 @@ module Jobs def execute(args) if topic = Topic.find_by(id: args[:topic_id]) closer = User.find_by(id: args[:user_id]) + guardian = Guardian.new(closer) + unless guardian.can_close?(topic) + closer = Discourse.system_user + end topic.auto_close(closer) end end diff --git a/lib/guardian.rb b/lib/guardian.rb index 1db182aa8ed..51cedb1e93a 100644 --- a/lib/guardian.rb +++ b/lib/guardian.rb @@ -114,6 +114,7 @@ class Guardian alias :can_move_posts? :can_moderate? alias :can_see_flags? :can_moderate? alias :can_send_activation_email? :can_moderate? + alias :can_close? :can_moderate? def can_grant_badges?(_user) SiteSetting.enable_badges && is_staff?