about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorTakeshi Umeda <noel.yoshiba@gmail.com>2020-03-31 03:32:34 +0900
committerGitHub <noreply@github.com>2020-03-30 20:32:34 +0200
commit11169367e4a999b19cc9140be38bdb5a1f3bb144 (patch)
tree9d48461c4a8de82deda1b15abffd49b191f81213 /app/services
parent0d117c106aa72f78dd5cdd371849dd8ce3120198 (diff)
Fix incorrect deletion of local accounts imported by overwriting (#13350)
Diffstat (limited to 'app/services')
-rw-r--r--app/services/import_service.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/app/services/import_service.rb b/app/services/import_service.rb
index 4ee431ea3..c0d741d57 100644
--- a/app/services/import_service.rb
+++ b/app/services/import_service.rb
@@ -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] }