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:
Selase Krakani 2024-07-11 16:47:21 +00:00 committed by GitHub
parent 7f0e6e9592
commit d896f5cb70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -859,13 +859,22 @@ class BulkImport::Generic < BulkImport::Base
name = user_full_name_from_id(user_id)
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 =
if username.present? && name.present?
%Q|[quote="#{name}, username:#{username}"]|
elsif username.present?
%Q|[quote="#{username}"]|
else
if username.blank? && name.blank?
"[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
raw.gsub!(quote["placeholder"], bbcode)