about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-04-27 08:48:21 +0200
committerClaire <claire.github-309c@sitedethib.com>2022-04-27 08:48:21 +0200
commitfc1dd81ea50e3a12ce6a298103a94d2f5445d7d2 (patch)
tree43038bf3550f8f162495dfc8d9cc077ad1da4052 /app/models
parenta481af15a9b2a7829c2a849906aa4b475ccdbd98 (diff)
parentbf75fba7942574f9b3b126084477693e9cc179c6 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `package.json`:
  Not a real conflict, upstream dependency updated textually too close to a
  glitch-soc-only dependency.
  Updated the upstream dependency.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/account.rb6
-rw-r--r--app/models/concerns/account_finder_concern.rb2
2 files changed, 7 insertions, 1 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index 1966c5a48..068ee7ae9 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -561,6 +561,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