mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 13:11:18 +08:00
FIX: corrently handle hidden tags when checking for edit conflicts
In 806e37aaec549069a599fd31edc16c5cdcd0774e, I improved the conflict handling when editing a post to account for title and tags. This fixes an edge cases when a topic has a hidden tag the current editor can't see. When they submit their edit, we automatically add the hidden tags before checking with the tags stored in the database. Reported in https://meta.discourse.org/t/341375
This commit is contained in:
@ -108,8 +108,15 @@ class DraftsController < ApplicationController
|
||||
|
||||
if post.post_number == 1
|
||||
conflict ||= original_title.present? && original_title != post.topic.title
|
||||
conflict ||=
|
||||
original_tags.present? && original_tags.sort != post.topic.tags.pluck(:name).sort
|
||||
|
||||
# Since the topic might have hidden tags the current editor can't see,
|
||||
# we need to check for conflicts even though there might not be any visible tags in the editor
|
||||
if !conflict
|
||||
original_tags = (original_tags || []).map(&:downcase).to_set
|
||||
current_tags = post.topic.tags.pluck(:name).to_set
|
||||
hidden_tags = DiscourseTagging.hidden_tag_names(@guardian).to_set
|
||||
conflict = original_tags != (current_tags - hidden_tags)
|
||||
end
|
||||
end
|
||||
|
||||
if conflict
|
||||
|
Reference in New Issue
Block a user