5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-30 06:36:21 +00:00

Merge branch 'sites-api' into panel.sutty.nl

This commit is contained in:
f 2022-03-08 15:11:05 -03:00
commit 98de45c2bf

View file

@ -9,7 +9,7 @@ module Api
# Lista de nombres de dominios a emitir certificados
def index
render json: sites_names + alternative_names + api_names
render json: sites_names + alternative_names + api_names + www_names
end
# Sitios con hidden service de Tor
@ -28,7 +28,7 @@ module Api
site = Site.find_by(name: params[:name])
if site
usuarie = GitAuthor.new email: 'tor@' + Site.domain, name: 'Tor'
usuarie = GitAuthor.new email: "tor@#{Site.domain}", name: 'Tor'
service = SiteService.new site: site, usuarie: usuarie,
params: params
service.add_onion
@ -39,14 +39,22 @@ module Api
private
def canonicalize(name)
name.end_with?('.') ? name[0..-2] : "#{name}.#{Site.domain}"
end
# Nombres de los sitios
def sites_names
Site.all.order(:name).pluck(:name)
Site.all.order(:name).pluck(:name).map do |name|
canonicalize name
end
end
# Dominios alternativos
def alternative_names
DeployAlternativeDomain.all.map(&:hostname) + DeployLocalizedDomain.all.map(&:hostname)
(DeployAlternativeDomain.all.map(&:hostname) + DeployLocalizedDomain.all.map(&:hostname)).map do |name|
canonicalize name
end
end
# Obtener todos los sitios con API habilitada, es decir formulario
@ -56,7 +64,17 @@ module Api
def api_names
Site.where(contact: true)
.or(Site.where(colaboracion_anonima: true))
.select("'api.' || name as name").map(&:name)
.select("'api.' || name as name").map(&:name).map do |name|
canonicalize name
end
end
def www_names
Site.where(contact: true)
.or(Site.where(colaboracion_anonima: true))
.select("'www.' || name as name").map(&:name).map do |name|
canonicalize name
end
end
end
end