FIX: Users without shared drafts access can still have access to the category. (#11476)

This is an edge-case of 9fb3629. An admin could set the shared draft category to one where both TL2 and TL3 users have access but only give shared draft access to TL3 users. If something like this happens, we need to make sure that TL2 users won't be able to see them, and they won't be listed on latest.

Before this change, `SharedDrafts` were lazily created when a destination category was selected. We now create it alongside the topic and set the destination to the same shared draft category.
This commit is contained in:
Roman Rizzi
2020-12-14 16:08:20 -03:00
committed by GitHub
parent c7b9f044a4
commit b45a30c40f
10 changed files with 79 additions and 15 deletions

View File

@ -56,8 +56,10 @@ class TopicCreator
private
def create_shared_draft(topic)
return unless @opts[:shared_draft] && @opts[:category].present?
SharedDraft.create(topic_id: topic.id, category_id: @opts[:category])
return if @opts[:shared_draft].blank? || @opts[:shared_draft] == 'false'
category_id = @opts[:category].blank? ? SiteSetting.shared_drafts_category.to_i : @opts[:category]
SharedDraft.create(topic_id: topic.id, category_id: category_id)
end
def create_warning(topic)