Addition of update activity distribution by alias, minor correction (#11905)

* Addition of update activity distribution by alias, minor correction

* Distribute Update activity after adding alias
* Add uniqueness verification to alias uri
* accept acct starting with @

* fix double-quoted to single-quoted
This commit is contained in:
Takeshi Umeda 2019-09-21 16:11:21 +09:00 committed by Eugen Rochko
parent e35636a0d1
commit f497d14b19
2 changed files with 7 additions and 0 deletions

View File

@ -15,6 +15,7 @@ class Settings::AliasesController < Settings::BaseController
@alias = current_account.aliases.build(resource_params) @alias = current_account.aliases.build(resource_params)
if @alias.save if @alias.save
ActivityPub::UpdateDistributionWorker.perform_async(current_account.id)
redirect_to settings_aliases_path, notice: I18n.t('aliases.created_msg') redirect_to settings_aliases_path, notice: I18n.t('aliases.created_msg')
else else
render :index render :index

View File

@ -17,11 +17,17 @@ class AccountAlias < ApplicationRecord
validates :acct, presence: true, domain: { acct: true } validates :acct, presence: true, domain: { acct: true }
validates :uri, presence: true validates :uri, presence: true
validates :uri, uniqueness: { scope: :account_id }
before_validation :set_uri before_validation :set_uri
after_create :add_to_account after_create :add_to_account
after_destroy :remove_from_account after_destroy :remove_from_account
def acct=(val)
val = val.to_s.strip
super(val.start_with?('@') ? val[1..-1] : val)
end
private private
def set_uri def set_uri