]> cat aescling's git repositories - mastodon.git/commitdiff
Fix incorrect deletion of local accounts imported by overwriting (#13350)
authorTakeshi Umeda <noel.yoshiba@gmail.com>
Mon, 30 Mar 2020 18:32:34 +0000 (03:32 +0900)
committerGitHub <noreply@github.com>
Mon, 30 Mar 2020 18:32:34 +0000 (20:32 +0200)
app/services/import_service.rb

index 4ee431ea33fb715e78e625ab34d0e9e26eff381d..c0d741d570904f6f11512523f72bfe46bafd0cf9 100644 (file)
@@ -64,7 +64,8 @@ class ImportService < BaseService
   end
 
   def import_relationships!(action, undo_action, overwrite_scope, limit, extra_fields = {})
-    items = @data.take(limit).map { |row| [row['Account address']&.strip, Hash[extra_fields.map { |key, header| [key, row[header]&.strip] }]] }.reject { |(id, _)| id.blank? }
+    local_domain_suffix = "@#{Rails.configuration.x.local_domain}"
+    items = @data.take(limit).map { |row| [row['Account address']&.strip&.delete_suffix(local_domain_suffix), Hash[extra_fields.map { |key, header| [key, row[header]&.strip] }]] }.reject { |(id, _)| id.blank? }
 
     if @import.overwrite?
       presence_hash = items.each_with_object({}) { |(id, extra), mapping| mapping[id] = [true, extra] }