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

This commit is contained in:
David Sainty 2024-07-13 00:53:39 +10:00
parent 18cb1cc2e5
commit 8e0466ac8f

View File

@ -1,5 +1,5 @@
# gossamer threads migration-import code # gossamer threads migration-import code
# v0.31.1 # v0.31.2
require 'mysql2' require 'mysql2'
require 'open-uri' require 'open-uri'
@ -1229,10 +1229,11 @@ class GossamerForumsImporter < ImportScripts::Base
# .where("title = ? OR title = ?", sanitized_title, "Re: #{sanitized_title}") # .where("title = ? OR title = ?", sanitized_title, "Re: #{sanitized_title}")
# .where(topic_custom_fields: { name: 'original_gossamer_msg_id' }) # .where(topic_custom_fields: { name: 'original_gossamer_msg_id' })
# .first # .first
topic = Topic.where.joins(:topic_allowed_users) topic = Topic.where(archetype: Archetype.private_message)
.where("topic_allowed_users.user_id = ? AND topic_allowed_users.user_id = ?", from_user_id, to_user_id) .where("topics.title = ? OR topics.title = ? OR topics.title = ?", sanitized_title, "Re: #{sanitized_title}", "Re: #{sanitized_title.strip}")
.where("title = ? OR title = ?", sanitized_title, "Re: #{sanitized_title}") .where("topics.topic_allowed_users.user_id = ? AND topics.topic_allowed_users.user_id = ?", from_user_id, to_user_id)
.first # .where("((topics.user_id = ? AND topics.topic_allowed_users.user_id = ?) OR (topics.user_id = ? AND topics.topic_allowed_users.user_id = ?))", from_user_id, to_user_id, to_user_id, from_user_id)
.first
if topic.nil? if topic.nil?
puts "IMPORTING new message topic sanitized: #{sanitized_title} user_id #{from_user_id} to_user_id #{to_user_id}" puts "IMPORTING new message topic sanitized: #{sanitized_title} user_id #{from_user_id} to_user_id #{to_user_id}"
@ -1301,17 +1302,17 @@ class GossamerForumsImporter < ImportScripts::Base
puts "Starting Gossamer Forums import... #{timestamp}" puts "Starting Gossamer Forums import... #{timestamp}"
add_former_user # add_former_user
# import_users # import_users
# export_username_mapping_to_csv("gossamer-migration-username-mapping#{timestamp}") # export_username_mapping_to_csv("gossamer-migration-username-mapping#{timestamp}")
# import_categories # import_categories
# # # import_topics_and_posts_with_attachments # # # import_topics_and_posts_with_attachments
update_topic_stats # update_topic_stats
update_user_stats # update_user_stats
export_url_mapping_to_csv("gossamer-migration-url-mapping#{timestamp}") # export_url_mapping_to_csv("gossamer-migration-url-mapping#{timestamp}")
create_nginx_rewrite_rules("gossamer-redirects#{timestamp}.conf") # create_nginx_rewrite_rules("gossamer-redirects#{timestamp}.conf")
import_personal_messages import_personal_messages