This repository has been archived on 2024-06-09. You can view files and clone it, but cannot push or open issues/pull-requests.
2019-07-19 01:44:42 +02:00
|
|
|
class AddInstanceActor < ActiveRecord::Migration[5.2]
|
2022-01-30 21:38:54 +01:00
|
|
|
class Account < ApplicationRecord
|
|
|
|
# Dummy class, to make migration possible across version changes
|
|
|
|
validates :username, uniqueness: { scope: :domain, case_sensitive: false }
|
2022-04-26 21:22:09 +02:00
|
|
|
|
|
|
|
before_create :generate_keys
|
|
|
|
|
|
|
|
def generate_keys
|
|
|
|
keypair = OpenSSL::PKey::RSA.new(2048)
|
|
|
|
self.private_key = keypair.to_pem
|
|
|
|
self.public_key = keypair.public_key.to_pem
|
|
|
|
end
|
2022-01-30 21:38:54 +01:00
|
|
|
end
|
|
|
|
|
2019-07-19 01:44:42 +02:00
|
|
|
def up
|
|
|
|
Account.create!(id: -99, actor_type: 'Application', locked: true, username: Rails.configuration.x.local_domain)
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
Account.find_by(id: -99, actor_type: 'Application').destroy!
|
|
|
|
end
|
|
|
|
end
|