v0.16.4 Profile image handling improvement

This commit is contained in:
David Sainty 2024-06-27 15:32:05 +10:00
parent c384aebed5
commit 04bca84117

View File

@ -1,5 +1,5 @@
# gossamer threads migration-import code # gossamer threads migration-import code
# v0.16.3 # v0.16.4
require 'mysql2' require 'mysql2'
require 'open-uri' require 'open-uri'
@ -501,10 +501,13 @@ class GossamerForumsImporter < ImportScripts::Base
puts "#E" puts "#E"
# Append the image to the user's bio # Append the image to the user's bio_raw only if it does not already exist
image_markdown = "\n\n![#{file['File_Name']}](#{file_url})"
user.user_profile.bio_raw ||= "" user.user_profile.bio_raw ||= ""
user.user_profile.bio_raw += "\n\n![#{file['File_Name']}](#{file_url})" unless user.user_profile.bio_raw.include?(image_markdown)
user.user_profile.bio_raw += image_markdown
user.user_profile.save! user.user_profile.save!
end
# Clean up temporary files # Clean up temporary files
temp_file.close temp_file.close