Skip to content

Commit 7c9d42c

Browse files
noellabohiyuki2578
authored andcommitted
Addition of update activity distribution by alias, minor correction (mastodon#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
1 parent 171f800 commit 7c9d42c

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

app/controllers/settings/aliases_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def create
1515
@alias = current_account.aliases.build(resource_params)
1616

1717
if @alias.save
18+
ActivityPub::UpdateDistributionWorker.perform_async(current_account.id)
1819
redirect_to settings_aliases_path, notice: I18n.t('aliases.created_msg')
1920
else
2021
render :index

app/models/account_alias.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@ class AccountAlias < ApplicationRecord
1717

1818
validates :acct, presence: true, domain: { acct: true }
1919
validates :uri, presence: true
20+
validates :uri, uniqueness: { scope: :account_id }
2021

2122
before_validation :set_uri
2223
after_create :add_to_account
2324
after_destroy :remove_from_account
2425

26+
def acct=(val)
27+
val = val.to_s.strip
28+
super(val.start_with?('@') ? val[1..-1] : val)
29+
end
30+
2531
private
2632

2733
def set_uri

0 commit comments

Comments
 (0)