mirror of
https://github.com/discourse/discourse.git
synced 2025-06-07 12:26:01 +08:00
DEV: Users must be able to see a topic to moderate it. (#10906)
Follows-up a8c47e7c. It makes more sense to check if the user can see the topic inside the `can_moderate?` method instead of doing it separately.
This commit is contained in:
@ -453,7 +453,6 @@ class TopicsController < ApplicationController
|
|||||||
params.require(:duration) if based_on_last_post
|
params.require(:duration) if based_on_last_post
|
||||||
|
|
||||||
topic = Topic.find_by(id: params[:topic_id])
|
topic = Topic.find_by(id: params[:topic_id])
|
||||||
guardian.ensure_can_see!(topic)
|
|
||||||
guardian.ensure_can_moderate!(topic)
|
guardian.ensure_can_moderate!(topic)
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
|
@ -170,7 +170,10 @@ class Guardian
|
|||||||
end
|
end
|
||||||
|
|
||||||
def can_moderate?(obj)
|
def can_moderate?(obj)
|
||||||
obj && authenticated? && !is_silenced? && (is_staff? || (obj.is_a?(Topic) && @user.has_trust_level?(TrustLevel[4])))
|
obj && authenticated? && !is_silenced? && (
|
||||||
|
is_staff? ||
|
||||||
|
(obj.is_a?(Topic) && @user.has_trust_level?(TrustLevel[4]) && can_see_topic?(obj))
|
||||||
|
)
|
||||||
end
|
end
|
||||||
alias :can_see_flags? :can_moderate?
|
alias :can_see_flags? :can_moderate?
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user