diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/account.rb | 6 | ||||
-rw-r--r-- | app/models/concerns/account_finder_concern.rb | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/app/models/account.rb b/app/models/account.rb index a8c5df208..7b460b054 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -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 diff --git a/app/models/concerns/account_finder_concern.rb b/app/models/concerns/account_finder_concern.rb index 0dadddad1..e8b804934 100644 --- a/app/models/concerns/account_finder_concern.rb +++ b/app/models/concerns/account_finder_concern.rb @@ -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 |