Move "everyone" role and "instance actor" account magic number IDs to constants (#29260)

This commit is contained in:
Matt Jankowski 2024-02-19 06:09:43 -05:00 committed by GitHub
parent 96ddf1d482
commit 245064bb98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 26 additions and 19 deletions

View file

@ -5,6 +5,8 @@ class AddInstanceActor < ActiveRecord::Migration[5.2]
# Dummy class, to make migration possible across version changes
validates :username, uniqueness: { scope: :domain, case_sensitive: false }
INSTANCE_ACTOR_ID = -99
before_create :generate_keys
def generate_keys
@ -15,10 +17,10 @@ class AddInstanceActor < ActiveRecord::Migration[5.2]
end
def up
Account.create!(id: -99, actor_type: 'Application', locked: true, username: Rails.configuration.x.local_domain)
Account.create!(id: Account::INSTANCE_ACTOR_ID, actor_type: 'Application', locked: true, username: Rails.configuration.x.local_domain)
end
def down
Account.find_by(id: -99, actor_type: 'Application').destroy!
Account.find_by(id: Account::INSTANCE_ACTOR_ID, actor_type: 'Application').destroy!
end
end