about summary refs log tree commit diff
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2020-02-26 22:35:43 -0600
committermultiple creatures <dev@multiple-creature.party>2020-02-26 22:35:43 -0600
commitacf8467ba73718ee8768bf2e9a6b0b4ff758775b (patch)
tree46cf3d2e474441fcb217257b18b159f4d18409ca
parentefe4a749a841fd794bfc4475b9864e046e786774 (diff)
**MAJOR**: don't trust inReplyTo fields in post imports that aren't self-replies
-rw-r--r--app/services/import_service.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/app/services/import_service.rb b/app/services/import_service.rb
index 93a0d8383..2ede7113e 100644
--- a/app/services/import_service.rb
+++ b/app/services/import_service.rb
@@ -154,14 +154,17 @@ class ImportService < BaseService
       json['hidden'] = [true, 1, "1"].include?(json['hidden'])
       json['imported'] = true
 
-      # drop a nonexistant conversation id
-      unless (json['conversation_id'] != 0 ? Conversation.where(id: json['conversation_id']).exists? : false)
+      # nullify a missing reply
+      s = Status.find_by(id: json['in_reply_to_id'])
+      if json['in_reply_to_id'] == 0 || s.nil? || s.account_id != @account.id
         json['conversation_id'] = nil
+      else
+        json['in_reply_to_id'] = nil
       end
 
-      # nullify a missing reply
-      unless (json['in_reply_to_id'] != 0 ? Status.where(id: json['in_reply_to_id']).exists? : false)
-        json['in_reply_to_id'] = nil
+      # drop a nonexistant conversation id
+      unless json['conversation_id'] == 0 || Conversation.where(id: json['conversation_id']).exists?
+        json['conversation_id'] = nil
       end
 
       ApplicationRecord.transaction do
@@ -209,6 +212,7 @@ class ImportService < BaseService
         object['attributedTo'] = account_uri
         object['to'] = activity['to']
         object['cc'] = activity['cc']
+        object['inReplyTo'] = nil
         object.delete('attachment')
       end