Fix situations in which instance actor can be set to a Mastodon-incompatible name (#22307)
* Validate internal actor * Use “internal.actor” by default for the server actor username * Fix instance actor username on the fly if it includes ':' * Change actor name from internal.actor to mastodon.internal
This commit is contained in:
parent
9b3e22c40d
commit
d1387579b9
3 changed files with 7 additions and 5 deletions
|
@ -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' }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue