Tackle the root issue with Discourse not playing ball with post min entropy 0 / post unclear issue

This commit is contained in:
David Sainty 2024-12-07 15:08:35 +11:00
parent 33a263b275
commit eeb5cb4798

View File

@ -1045,8 +1045,12 @@ class GossamerForumsImporter < ImportScripts::Base
# Ensure the raw post string contents itself is acceptable to Discourse
sanitized_message = message&.tr("\0", '') || ""
# Remove the [signature] as we don't support this in Discourse
# sanitized_message.sub!(/\n?\[signature\]\n?\z/, '')
sanitized_message.gsub(/\n?\[signature\]\n?/, '')
# Ensure minimum length
if sanitized_message.strip.empty? || sanitized_message.length < 3
if sanitized_message.strip.empty? || sanitized_message.length < 5
sanitized_message = "Empty post contents."
end
@ -1055,10 +1059,6 @@ class GossamerForumsImporter < ImportScripts::Base
sanitized_message += "."
end
# Remove the [signature] as we don't support this in Discourse
# sanitized_message.sub!(/\n?\[signature\]\n?\z/, '')
sanitized_message.gsub(/\n?\[signature\]\n?/, '')
# Convert Gossamer tags to Discourse markdown
sanitized_message.gsub!(/\[b\](.*?)\[\/b\]/, '**\1**')
sanitized_message.gsub!(/\[i\](.*?)\[\/i\]/, '*\1*')