From bb12fa3fdcaf6c26362a9a07f66b052bb75f4e98 Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Mon, 21 May 2018 18:19:22 +0530 Subject: [PATCH] Migrate user mentions in lithium import --- script/import_scripts/lithium.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/script/import_scripts/lithium.rb b/script/import_scripts/lithium.rb index 25fd75fb35b..108fec921e5 100644 --- a/script/import_scripts/lithium.rb +++ b/script/import_scripts/lithium.rb @@ -944,6 +944,21 @@ SQL end + # for user mentions + doc.css("li-user").each do |l| + uid = l["uid"] + + if uid.present? + user = UserCustomField.find_by(name: 'import_id', value: uid).try(:user) + if user.present? + username = user.username + span = doc.create_element "span" + span.inner_html = "@#{username}" + l.replace span + end + end + end + raw = ReverseMarkdown.convert(doc.to_s) raw.gsub!(/^\s* \s*$/, "") # ugly quotes