mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 17:01:09 +08:00
DEV: Include post and topic attributes in imported quotes (#27851)
Currently, quotes imported via generic bulk import script do not include references to the quoted post. This change includes both topic and post attributes in a quote if the placeholder metadata includes a `post_id`
This commit is contained in:
@ -859,13 +859,22 @@ class BulkImport::Generic < BulkImport::Base
|
|||||||
name = user_full_name_from_id(user_id)
|
name = user_full_name_from_id(user_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if quote["post_id"]
|
||||||
|
topic_id = topic_id_from_imported_post_id(quote["post_id"])
|
||||||
|
post_number = post_number_from_imported_id(quote["post_id"])
|
||||||
|
end
|
||||||
|
|
||||||
bbcode =
|
bbcode =
|
||||||
if username.present? && name.present?
|
if username.blank? && name.blank?
|
||||||
%Q|[quote="#{name}, username:#{username}"]|
|
|
||||||
elsif username.present?
|
|
||||||
%Q|[quote="#{username}"]|
|
|
||||||
else
|
|
||||||
"[quote]"
|
"[quote]"
|
||||||
|
else
|
||||||
|
bbcode_parts = []
|
||||||
|
bbcode_parts << name.presence || username
|
||||||
|
bbcode_parts << "post:#{post_number}" if post_number.present?
|
||||||
|
bbcode_parts << "topic:#{topic_id}" if topic_id.present?
|
||||||
|
bbcode_parts << "username:#{username}" if username.present? && name.present?
|
||||||
|
|
||||||
|
%Q|[quote="#{bbcode_parts.join(", ")}"]|
|
||||||
end
|
end
|
||||||
|
|
||||||
raw.gsub!(quote["placeholder"], bbcode)
|
raw.gsub!(quote["placeholder"], bbcode)
|
||||||
|
Reference in New Issue
Block a user