Fix instance actor being incorrectly created when running migrations (#18109)
* Add migration test about instance actor key * Fix old migration * Work around incorrect database state
This commit is contained in:
parent
f47a9ddc9f
commit
33cd80d69c
4 changed files with 20 additions and 1 deletions
|
@ -559,6 +559,12 @@ class Account < ApplicationRecord
|
|||
before_validation :prepare_username, on: :create
|
||||
before_destroy :clean_feed_manager
|
||||
|
||||
def ensure_keys!
|
||||
return unless local? && private_key.blank? && public_key.blank?
|
||||
generate_keys
|
||||
save!
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def prepare_contents
|
||||
|
|
|
@ -13,7 +13,7 @@ module AccountFinderConcern
|
|||
end
|
||||
|
||||
def representative
|
||||
Account.find(-99)
|
||||
Account.find(-99).tap(&:ensure_keys!)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
Account.create!(id: -99, actor_type: 'Application', locked: true, username: Rails.configuration.x.local_domain)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue