Migrate user mentions in lithium import

This commit is contained in:
Vinoth Kannan 2018-05-21 18:19:22 +05:30
parent 37ad2dd936
commit bb12fa3fdc
1 changed files with 15 additions and 0 deletions

View File

@ -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