From f497d14b19ce150ee19e6478c9018833e28c7d52 Mon Sep 17 00:00:00 2001 From: Takeshi Umeda Date: Sat, 21 Sep 2019 16:11:21 +0900 Subject: [PATCH] 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 --- app/controllers/settings/aliases_controller.rb | 1 + app/models/account_alias.rb | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/app/controllers/settings/aliases_controller.rb b/app/controllers/settings/aliases_controller.rb index da0a4a9fa67..b7c9a409d1f 100644 --- a/app/controllers/settings/aliases_controller.rb +++ b/app/controllers/settings/aliases_controller.rb @@ -15,6 +15,7 @@ class Settings::AliasesController < Settings::BaseController @alias = current_account.aliases.build(resource_params) if @alias.save + ActivityPub::UpdateDistributionWorker.perform_async(current_account.id) redirect_to settings_aliases_path, notice: I18n.t('aliases.created_msg') else render :index diff --git a/app/models/account_alias.rb b/app/models/account_alias.rb index e9a0dd79e03..66f8ce40953 100644 --- a/app/models/account_alias.rb +++ b/app/models/account_alias.rb @@ -17,11 +17,17 @@ class AccountAlias < ApplicationRecord validates :acct, presence: true, domain: { acct: true } validates :uri, presence: true + validates :uri, uniqueness: { scope: :account_id } before_validation :set_uri after_create :add_to_account after_destroy :remove_from_account + def acct=(val) + val = val.to_s.strip + super(val.start_with?('@') ? val[1..-1] : val) + end + private def set_uri