v0.31.1 Significant update of private message code - field population, threading of replies, visibility to sender

This commit is contained in:
David Sainty 2024-07-12 23:57:27 +10:00
parent 5395e7984e
commit 18cb1cc2e5

View File

@ -1,5 +1,5 @@
# gossamer threads migration-import code
# v0.31
# v0.31.1
require 'mysql2'
require 'open-uri'
@ -1190,7 +1190,7 @@ class GossamerForumsImporter < ImportScripts::Base
puts "Highest processed personal_id: #{highest_processed_personal_id}"
# OVERRIDE - to speed getting to problem msg
# highest_processed_personal_id = 350
highest_processed_personal_id = 1543840
puts "Highest processed personal_id override: #{highest_processed_personal_id}"
execute_query("SELECT * FROM gforum_Message").each do |row|
@ -1223,11 +1223,15 @@ class GossamerForumsImporter < ImportScripts::Base
sanitized_title = "<no subject>" if sanitized_title.nil? || sanitized_title.empty?
# Check for an existing private message topic between the same two users with a similar title
topic = Topic.joins(:topic_allowed_users, :custom_fields)
.where(archetype: Archetype.private_message)
# topic = Topic.joins(:topic_allowed_users, :custom_fields)
# .where(archetype: Archetype.private_message)
# .where("topic_allowed_users.user_id = ? AND topic_allowed_users.user_id = ?", from_user_id, to_user_id)
# .where("title = ? OR title = ?", sanitized_title, "Re: #{sanitized_title}")
# .where(topic_custom_fields: { name: 'original_gossamer_msg_id' })
# .first
topic = Topic.where.joins(:topic_allowed_users)
.where("topic_allowed_users.user_id = ? AND topic_allowed_users.user_id = ?", from_user_id, to_user_id)
.where("title = ? OR title = ?", sanitized_title, "Re: #{sanitized_title}")
.where(topic_custom_fields: { name: 'original_gossamer_msg_id' })
.first
if topic.nil?