mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Existing shared drafts should be accessible (#11915)
Disabling shared drafts used to leave topics in an inconsistent state where they were not displayed as shared drafts and thus there was no way of publishing them. Moreover, they were accessible just to users who have permissions to create shared drafts. This commit adds another permission check that is used for most operations and the old can_create_shared_draft? remains used just when creating a new shared draft.
This commit is contained in:
@@ -142,7 +142,7 @@ module PostGuardian
|
||||
can_create_post?(post.topic) &&
|
||||
post.topic.category_id == SiteSetting.shared_drafts_category.to_i &&
|
||||
can_see_category?(post.topic.category) &&
|
||||
can_create_shared_draft?
|
||||
can_see_shared_draft?
|
||||
)
|
||||
|
||||
if post.wiki && (@user.trust_level >= SiteSetting.min_trust_to_edit_wiki_post.to_i)
|
||||
|
||||
@@ -22,8 +22,10 @@ module TopicGuardian
|
||||
alias :can_moderate_topic? :can_review_topic?
|
||||
|
||||
def can_create_shared_draft?
|
||||
return false unless SiteSetting.shared_drafts_enabled?
|
||||
SiteSetting.shared_drafts_enabled? && can_see_shared_draft?
|
||||
end
|
||||
|
||||
def can_see_shared_draft?
|
||||
return is_admin? if SiteSetting.shared_drafts_min_trust_level.to_s == 'admin'
|
||||
return is_staff? if SiteSetting.shared_drafts_min_trust_level.to_s == 'staff'
|
||||
|
||||
@@ -39,7 +41,7 @@ module TopicGuardian
|
||||
end
|
||||
|
||||
def can_publish_topic?(topic, category)
|
||||
can_create_shared_draft? && can_see?(topic) && can_create_topic_on_category?(category)
|
||||
can_see_shared_draft? && can_see?(topic) && can_create_topic_on_category?(category)
|
||||
end
|
||||
|
||||
# Creating Methods
|
||||
@@ -102,7 +104,7 @@ module TopicGuardian
|
||||
!topic.private_message? &&
|
||||
topic.category_id == SiteSetting.shared_drafts_category.to_i &&
|
||||
can_see_category?(topic.category) &&
|
||||
can_create_shared_draft? &&
|
||||
can_see_shared_draft? &&
|
||||
can_create_post?(topic)
|
||||
)
|
||||
|
||||
@@ -176,7 +178,7 @@ module TopicGuardian
|
||||
return authenticated? && topic.all_allowed_users.where(id: @user.id).exists?
|
||||
end
|
||||
|
||||
return false if topic.shared_draft && !can_create_shared_draft?
|
||||
return false if topic.shared_draft && !can_see_shared_draft?
|
||||
|
||||
category = topic.category
|
||||
can_see_category?(category) &&
|
||||
|
||||
Reference in New Issue
Block a user