5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-10-05 08:16:57 +00:00

Merge branch 'distributed-press' into panel.sutty.nl

This commit is contained in:
f 2023-02-09 20:02:43 -03:00
commit d1d4cdcded
4 changed files with 30 additions and 0 deletions

View file

@ -41,6 +41,7 @@ gem 'devise'
gem 'devise-i18n'
gem 'devise_invitable'
gem 'distributed-press-api-client', '~> 0.2.2'
gem 'njalla-api-client'
gem 'email_address', git: 'https://github.com/fauno/email_address', branch: 'i18n'
gem 'exception_notification'
gem 'fast_blank'

View file

@ -357,6 +357,9 @@ GEM
nokogiri (1.13.10-x86_64-linux-musl)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
njalla-api-client (0.1.0)
dry-schema
httparty (~> 0.18)
orm_adapter (0.5.0)
parallel (1.22.1)
parser (3.1.3.0)
@ -618,6 +621,7 @@ DEPENDENCIES
mini_magick
mobility
net-ssh
njalla-api-client
nokogiri
pg
pg_search

View file

@ -113,6 +113,12 @@ class DeployDistributedPress < Deploy
self.remote_site_id = created_site[:id]
self.remote_info = created_site.to_h
# XXX: Esto depende de nuestro DNS actual, cuando lo migremos hay
# que eliminarlo.
self.remote_info['njalla'] = {}
self.remote_info['njalla']['a'] = njalla.add_record(name: site.name, type: 'CNAME', content: "#{Site.domain}.").to_h
self.remote_info['njalla']['ns'] = njalla.add_record(name: "_dnslink.#{site.name}", type: 'NS', content: "#{publisher.hostname}.").to_h
nil
end
@ -125,4 +131,16 @@ class DeployDistributedPress < Deploy
build_stats.create action: publisher.to_s,log: log, seconds: time_spent_in_seconds, bytes: size, status: status
nil
end
# Actualizar registros en Njalla
#
# @return [Njalla::V1::Domain]
def njalla
@njalla ||=
begin
client = Njalla::V1::Client.new(token: ENV['NJALLA_TOKEN'])
Njalla::V1::Domain.new(domain: Site.domain, client: client)
end
end
end

View file

@ -40,6 +40,13 @@ class DistributedPressPublisher < ApplicationRecord
"Distributed Press <#{instance}>"
end
# Devuelve el hostname de la instancia
#
# @return [String]
def hostname
@hostname ||= URI.parse(instance).hostname
end
# @return [Logger]
def logger
@logger ||=