20240607
This commit is contained in:
parent
33ea3e2d6a
commit
0358a1cc0b
@ -489,6 +489,22 @@ def import_personal_messages
|
||||
|
||||
# Skip if the message already exists
|
||||
unless TopicCustomField.exists?(name: 'original_gossamer_msg_id', value: row['msg_id'])
|
||||
|
||||
# Sanitize the message, ensuring we have an empty string or the content without any \0
|
||||
sanitized_message = row['msg_body']&.tr("\0", '') || ""
|
||||
|
||||
# Set default message body if the sanitized message is blank
|
||||
sanitized_message = " " if sanitized_message.strip.empty?
|
||||
|
||||
# # If we do not change the "min personal message post length" to 1, we need this.
|
||||
# sanitized_message = sanitized_message.ljust(10, ' ') if sanitized_message.length < 10
|
||||
|
||||
# Check and set a default title if the original title is nil or empty
|
||||
title = row['msg_subject']&.strip
|
||||
title = "<no subject>" if title.nil? || title.empty?
|
||||
|
||||
puts "IMPORTING title #{row['msg_subject']} user_id #{from_user_id} to_user_id #{to_user_id}"
|
||||
|
||||
# Create a private message topic in Discourse
|
||||
topic = Topic.create!(
|
||||
title: row['msg_subject'],
|
||||
@ -501,7 +517,6 @@ def import_personal_messages
|
||||
topic.save!
|
||||
|
||||
# Create the message as a post in the private topic
|
||||
sanitized_message = row['msg_body']&.tr("\0", '') || ""
|
||||
post = Post.create!(
|
||||
topic_id: topic.id,
|
||||
user_id: from_user_id,
|
||||
|
Loading…
Reference in New Issue
Block a user