mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-26 02:26:23 +00:00
23 lines
579 B
Ruby
23 lines
579 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Site
|
|
# Agrega soporte para Social Distributed Press en los sitios
|
|
module SocialDistributedPress
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
encrypts :private_key_pem
|
|
|
|
before_save :generate_private_key_pem!, unless: :private_key_pem?
|
|
|
|
private
|
|
|
|
# Genera la llave privada y la almacena
|
|
#
|
|
# @return [nil]
|
|
def generate_private_key_pem!
|
|
self.private_key_pem ||= DistributedPress::V1::Social::Client.new(public_key_url: nil, key_size: 2048).private_key.export
|
|
end
|
|
end
|
|
end
|
|
end
|