diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/account_alias.rb | 9 | ||||
-rw-r--r-- | app/views/settings/aliases/index.html.haml | 10 |
2 files changed, 16 insertions, 3 deletions
diff --git a/app/models/account_alias.rb b/app/models/account_alias.rb index 66f8ce409..3d0b5d188 100644 --- a/app/models/account_alias.rb +++ b/app/models/account_alias.rb @@ -18,6 +18,7 @@ class AccountAlias < ApplicationRecord validates :acct, presence: true, domain: { acct: true } validates :uri, presence: true validates :uri, uniqueness: { scope: :account_id } + validate :validate_target_account before_validation :set_uri after_create :add_to_account @@ -44,4 +45,12 @@ class AccountAlias < ApplicationRecord def remove_from_account account.update(also_known_as: account.also_known_as.reject { |x| x == uri }) end + + def validate_target_account + if uri.nil? + 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')) + end + end end diff --git a/app/views/settings/aliases/index.html.haml b/app/views/settings/aliases/index.html.haml index 5b6986368..5df0c9669 100644 --- a/app/views/settings/aliases/index.html.haml +++ b/app/views/settings/aliases/index.html.haml @@ -23,7 +23,11 @@ %th= t('simple_form.labels.account_alias.acct') %th %tbody - - @aliases.each do |account_alias| + - if @aliases.empty? %tr - %td= account_alias.acct - %td= table_link_to 'trash', t('aliases.remove'), settings_alias_path(account_alias), data: { method: :delete } + %td.muted-hint{ colspan: 2 }= t('aliases.empty') + - else + - @aliases.each do |account_alias| + %tr + %td= account_alias.acct + %td= table_link_to 'trash', t('aliases.remove'), settings_alias_path(account_alias), data: { method: :delete } |