mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Fix account aliases page (#13452)
* Fix error not being displayed when adding an account alias, add error for self-references Co-Authored-By: Mélanie Chauvel (ariasuni) <perso@hack-libre.org> * Add “You have no aliases.” note in confusing empty aliases table Co-Authored-By: Mélanie Chauvel (ariasuni) <perso@hack-libre.org> Co-authored-by: Mélanie Chauvel (ariasuni) <perso@hack-libre.org>
This commit is contained in:
parent
490ff09c5a
commit
f7e011919e
3 changed files with 17 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -635,6 +635,7 @@ en:
|
|||
add_new: Create alias
|
||||
created_msg: Successfully created a new alias. You can now initiate the move from the old account.
|
||||
deleted_msg: Successfully remove the alias. Moving from that account to this one will no longer be possible.
|
||||
empty: You have no aliases.
|
||||
hint_html: If you want to move from another account to this one, here you can create an alias, which is required before you can proceed with moving followers from the old account to this one. This action by itself is <strong>harmless and reversible</strong>. <strong>The account migration is initiated from the old account</strong>.
|
||||
remove: Unlink alias
|
||||
appearance:
|
||||
|
|
Loading…
Reference in a new issue