From 03b971c3e36e307f5e4dcad0a7a9cef13fbcec75 Mon Sep 17 00:00:00 2001 From: riking Date: Fri, 27 Mar 2015 15:31:04 -0700 Subject: [PATCH] FIX: Don't fail topic auto-close if privledges are lost --- app/jobs/regular/close_topic.rb | 4 ++++ lib/guardian.rb | 1 + 2 files changed, 5 insertions(+) diff --git a/app/jobs/regular/close_topic.rb b/app/jobs/regular/close_topic.rb index 61a27588c..0703c971f 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 d3e2911ee..367ac11cd 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?