5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 03:46:23 +00:00
panel/app/models/site/social_distributed_press.rb
2024-02-23 12:53:56 -03:00

35 lines
809 B
Ruby

# frozen_string_literal: true
require 'distributed_press/v1/social/client'
class Site
# Agrega soporte para Social Distributed Press en los sitios
module SocialDistributedPress
extend ActiveSupport::Concern
included do
has_encrypted :private_key_pem
has_many :activity_pubs
before_save :generate_private_key_pem!, unless: :private_key_pem?
# @return [SocialInbox]
def social_inbox
@social_inbox ||= SocialInbox.new(site: self)
end
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