mirror of
https://0xacab.org/sutty/sutty
synced 2025-03-14 21:08:18 +00:00
Merge branch 'issue-18074' into production.panel.sutty.nl
This commit is contained in:
commit
18910c43f3
1 changed files with 27 additions and 18 deletions
|
@ -5,6 +5,7 @@ module Api
|
||||||
# API para sitios
|
# API para sitios
|
||||||
class SitesController < BaseController
|
class SitesController < BaseController
|
||||||
SUBDOMAIN = ".#{Site.domain}"
|
SUBDOMAIN = ".#{Site.domain}"
|
||||||
|
TESTING_SUBDOMAIN = ".testing.#{SUBDOMAIN}"
|
||||||
PARTS = Site.domain.split('.').count
|
PARTS = Site.domain.split('.').count
|
||||||
|
|
||||||
if Rails.env.production?
|
if Rails.env.production?
|
||||||
|
@ -14,7 +15,15 @@ module Api
|
||||||
|
|
||||||
# Lista de nombres de dominios a emitir certificados
|
# Lista de nombres de dominios a emitir certificados
|
||||||
def index
|
def index
|
||||||
render json: sites_names.concat(alternative_names).concat(api_names).concat(www_names)
|
all_names = sites_names.concat(alternative_names).concat(api_names).concat(www_names).uniq.map do |name|
|
||||||
|
canonicalize name
|
||||||
|
end.reject do |name|
|
||||||
|
subdomain? name
|
||||||
|
end.reject do |name|
|
||||||
|
testing? name
|
||||||
|
end.uniq
|
||||||
|
|
||||||
|
render json: all_names
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -37,24 +46,28 @@ module Api
|
||||||
name.end_with?(SUBDOMAIN) && name.split('.').count == (PARTS + 1)
|
name.end_with?(SUBDOMAIN) && name.split('.').count == (PARTS + 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Nombres de los sitios
|
# Es un dominio de prueba
|
||||||
def sites_names
|
#
|
||||||
Site.all.order(:name).pluck(:name).map do |name|
|
# @param name [String]
|
||||||
canonicalize name
|
# @return [Bool]
|
||||||
end.reject do |name|
|
def testing?(name)
|
||||||
subdomain? name
|
name.end_with?(TESTING_SUBDOMAIN) && name.split('.').count == (PARTS + 2)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dominios alternativos
|
# Nombres de los sitios
|
||||||
|
#
|
||||||
|
# @param name [String]
|
||||||
|
# @return [Array<String>]
|
||||||
|
def sites_names
|
||||||
|
Site.all.order(:name).pluck(:name)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Dominios alternativos, incluyendo todas las clases derivadas de
|
||||||
|
# esta.
|
||||||
#
|
#
|
||||||
# @return [Array<String>]
|
# @return [Array<String>]
|
||||||
def alternative_names
|
def alternative_names
|
||||||
hostname_of(DeployAlternativeDomain.all).concat(hostname_of(DeployLocalizedDomain)).map do |name|
|
hostname_of(DeployAlternativeDomain.all)
|
||||||
canonicalize name
|
|
||||||
end.reject do |name|
|
|
||||||
subdomain? name
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Obtener todos los sitios con API habilitada, es decir formulario
|
# Obtener todos los sitios con API habilitada, es decir formulario
|
||||||
|
@ -66,10 +79,6 @@ module Api
|
||||||
.or(Site.where(colaboracion_anonima: true))
|
.or(Site.where(colaboracion_anonima: true))
|
||||||
.pluck(:name).map do |name|
|
.pluck(:name).map do |name|
|
||||||
"api.#{name}"
|
"api.#{name}"
|
||||||
end.map do |name|
|
|
||||||
canonicalize name
|
|
||||||
end.reject do |name|
|
|
||||||
subdomain? name
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue