diff --git a/app/models/account.rb b/app/models/account.rb index b27fc748f9d..262285a09ec 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -84,8 +84,8 @@ class Account < ApplicationRecord validates :username, presence: true validates_with UniqueUsernameValidator, if: -> { will_save_change_to_username? } - # Remote user validations - validates :username, format: { with: USERNAME_ONLY_RE }, if: -> { !local? && will_save_change_to_username? } + # Remote user validations, also applies to internal actors + validates :username, format: { with: USERNAME_ONLY_RE }, if: -> { (!local? || actor_type == 'Application') && will_save_change_to_username? } # Local user validations validates :username, format: { with: /\A[a-z0-9_]+\z/i }, length: { maximum: 30 }, if: -> { local? && will_save_change_to_username? && actor_type != 'Application' } diff --git a/app/models/concerns/account_finder_concern.rb b/app/models/concerns/account_finder_concern.rb index e8b804934a5..37c3b889593 100644 --- a/app/models/concerns/account_finder_concern.rb +++ b/app/models/concerns/account_finder_concern.rb @@ -13,9 +13,11 @@ module AccountFinderConcern end def representative - Account.find(-99).tap(&:ensure_keys!) + actor = Account.find(-99).tap(&:ensure_keys!) + actor.update!(username: 'mastodon.internal') if actor.username.include?(':') + actor rescue ActiveRecord::RecordNotFound - Account.create!(id: -99, actor_type: 'Application', locked: true, username: Rails.configuration.x.local_domain) + Account.create!(id: -99, actor_type: 'Application', locked: true, username: 'mastodon.internal') end def find_local(username) diff --git a/db/seeds/02_instance_actor.rb b/db/seeds/02_instance_actor.rb index 39186b27344..f9aa372f1c4 100644 --- a/db/seeds/02_instance_actor.rb +++ b/db/seeds/02_instance_actor.rb @@ -1 +1 @@ -Account.create_with(actor_type: 'Application', locked: true, username: ENV['LOCAL_DOMAIN'] || Rails.configuration.x.local_domain).find_or_create_by(id: -99) +Account.create_with(actor_type: 'Application', locked: true, username: 'mastodon.internal').find_or_create_by(id: -99)