2023-08-29 20:43:19 +00:00
|
|
|
# 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
|
2023-08-29 20:49:25 +00:00
|
|
|
|
|
|
|
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!
|
2024-01-12 20:34:27 +00:00
|
|
|
self.private_key_pem ||= ::DistributedPress::V1::Social::Client.new(public_key_url: nil, key_size: 2048).private_key.export
|
2023-08-29 20:49:25 +00:00
|
|
|
end
|
2023-08-29 20:43:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|