mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-19 22:26:23 +00:00
chore: rubocop
This commit is contained in:
parent
b24f49fe26
commit
b4117d7c34
5 changed files with 26 additions and 23 deletions
|
@ -18,13 +18,14 @@ module Api
|
|||
def token
|
||||
@token ||=
|
||||
begin
|
||||
_headers = request.headers
|
||||
_token ||= _headers['X-Gitlab-Token'].presence
|
||||
_token ||= token_from_signature(_headers['X-Gitea-Signature'].presence)
|
||||
_token ||= token_from_signature(_headers['X-Hub-Signature-256'].presence, 'sha256=')
|
||||
_token
|
||||
header = request.headers
|
||||
token = header['X-Social-Inbox'].presence
|
||||
token ||= header['X-Gitlab-Token'].presence
|
||||
token ||= token_from_signature(header['X-Gitea-Signature'].presence)
|
||||
token ||= token_from_signature(header['X-Hub-Signature-256'].presence, 'sha256=')
|
||||
token
|
||||
ensure
|
||||
raise ActiveRecord::RecordNotFound, 'Proveedor no soportado' if _token.blank?
|
||||
raise ActiveRecord::RecordNotFound, 'Proveedor no soportado' if token.blank?
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ class Deploy < ApplicationRecord
|
|||
|
||||
has_many :build_stats, dependent: :destroy
|
||||
|
||||
DEPENDENCIES = []
|
||||
SOFT_DEPENDENCIES = []
|
||||
DEPENDENCIES = [].freeze
|
||||
SOFT_DEPENDENCIES = [].freeze
|
||||
|
||||
def deploy(**)
|
||||
raise NotImplementedError
|
||||
|
@ -74,7 +74,7 @@ class Deploy < ApplicationRecord
|
|||
'HOME' => home_dir,
|
||||
'PATH' => paths.join(':'),
|
||||
'JEKYLL_ENV' => Rails.env,
|
||||
'LANG' => ENV['LANG'],
|
||||
'LANG' => ENV.fetch('LANG', nil)
|
||||
})
|
||||
end
|
||||
|
||||
|
@ -139,7 +139,7 @@ class Deploy < ApplicationRecord
|
|||
# provisto con el archivo como parámetro
|
||||
#
|
||||
# @param :content [String]
|
||||
def with_tempfile(content, &block)
|
||||
def with_tempfile(content)
|
||||
Tempfile.create(SecureRandom.hex) do |file|
|
||||
file.write content.to_s
|
||||
file.rewind
|
||||
|
|
|
@ -5,7 +5,7 @@ require 'distributed_press/v1/social/client'
|
|||
# Publicar novedades al Fediverso
|
||||
class DeploySocialDistributedPress < Deploy
|
||||
# Solo luego de publicar remotamente
|
||||
DEPENDENCIES = %i[deploy_distributed_press deploy_rsync deploy_full_rsync]
|
||||
DEPENDENCIES = %i[deploy_distributed_press deploy_rsync deploy_full_rsync].freeze
|
||||
|
||||
after_save :create_hooks!
|
||||
|
||||
|
@ -70,17 +70,21 @@ class DeploySocialDistributedPress < Deploy
|
|||
# @return [nil]
|
||||
def create_hooks!
|
||||
hook_client = site.social_inbox.hook
|
||||
webhook_class = DistributedPress::V1::Social::Schemas::Webhook
|
||||
|
||||
hook_client.class::EVENTS.each do |event|
|
||||
event_url = :"v1_site_webhooks_social_inbox_#{event}_url"
|
||||
|
||||
webhook = DistributedPress::V1::Social::Schemas::Webhook.new.call({
|
||||
method: 'POST',
|
||||
url: Rails.application.routes.url_helpers.public_send(event_url, site_id: site.name, host: api_hostname),
|
||||
headers: {
|
||||
'X-Social-Inbox': rol.token
|
||||
}
|
||||
})
|
||||
webhook =
|
||||
webhook_class.new.call({
|
||||
method: 'POST',
|
||||
url: Rails.application.routes.url_helpers.public_send(
|
||||
event_url, site_id: site.name, host: api_hostname
|
||||
),
|
||||
headers: {
|
||||
'X-Social-Inbox': rol.token
|
||||
}
|
||||
})
|
||||
|
||||
raise ArgumentError, webhook.errors.messages if webhook.failure?
|
||||
|
||||
|
|
|
@ -25,7 +25,8 @@ class Site
|
|||
def generate_private_key_pem!
|
||||
self.private_key_pem ||= DistributedPress::V1::Social::Client.new(
|
||||
public_key_url: nil,
|
||||
key_size: 2048).private_key.export
|
||||
key_size: 2048
|
||||
).private_key.export
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -50,9 +50,6 @@ class SocialInbox
|
|||
|
||||
def hostname
|
||||
@hostname ||=
|
||||
begin
|
||||
host = site.config.dig('activity_pub', 'hostname')
|
||||
host ||= site.hostname
|
||||
end
|
||||
site.config.dig('activity_pub', 'hostname') || site.hostname
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue