about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-04-15 20:33:53 +0200
committerGitHub <noreply@github.com>2020-04-15 20:33:53 +0200
commit3825e1943f3e870ffe967f01d6ca4345d69f1a12 (patch)
tree7919a3873bbb3650f380674af55a5d7cf482b3a0 /app/models
parent5edff32733eff2cbffbf614b31eea85da8dc3aaf (diff)
Fix confusing error when failing to add an alias to an unknown account (#13480)
Follow-up to #13452, fixing broken `uri.nil?` test.

Also remove the separate check for `uri` presence, as that would result
in a “Please review 2 errors below” while only one would be listed.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/account_alias.rb3
1 files changed, 1 insertions, 2 deletions
diff --git a/app/models/account_alias.rb b/app/models/account_alias.rb
index 3d0b5d188..792e9e8d4 100644
--- a/app/models/account_alias.rb
+++ b/app/models/account_alias.rb
@@ -16,7 +16,6 @@ class AccountAlias < ApplicationRecord
   belongs_to :account
 
   validates :acct, presence: true, domain: { acct: true }
-  validates :uri, presence: true
   validates :uri, uniqueness: { scope: :account_id }
   validate :validate_target_account
 
@@ -47,7 +46,7 @@ class AccountAlias < ApplicationRecord
   end
 
   def validate_target_account
-    if uri.nil?
+    if uri.blank?
       errors.add(:acct, I18n.t('migrations.errors.not_found'))
     elsif ActivityPub::TagManager.instance.uri_for(account) == uri
       errors.add(:acct, I18n.t('migrations.errors.move_to_self'))