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

This commit is contained in:
David Sainty 2024-07-13 01:38:08 +10:00
parent 78f779fb76
commit b542dcfd27

View File

@ -1,5 +1,5 @@
# gossamer threads migration-import code
# v0.31.3
# v0.31.4
require 'mysql2'
require 'open-uri'
@ -1231,11 +1231,12 @@ class GossamerForumsImporter < ImportScripts::Base
# .first
topic = Topic.joins(:topic_allowed_users)
.where(archetype: Archetype.private_message)
.where("topics.title = ? OR topics.title = ? OR topics.title = ?", sanitized_title, "Re: #{sanitized_title}", "Re: #{sanitized_title.strip}")
.where("topics.title = ? OR topics.title = ?", sanitized_title, sanitized_title.gsub(/^Re: /, ""))
.where("topic_allowed_users.user_id IN (?)", [from_user_id, to_user_id])
.group("topics.id")
.having("COUNT(topic_allowed_users.user_id) = 2")
.first
# .where("topics.title = ? OR topics.title = ?", sanitized_title, sanitized_title.gsub(/^Re: /, ""))
# .where("topics.topic_allowed_users.user_id = ? AND topics.topic_allowed_users.user_id = ?", from_user_id, to_user_id)
# .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)