mirror of
https://0xacab.org/sutty/sutty
synced 2025-03-14 17:58:16 +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
|
||||
class SitesController < BaseController
|
||||
SUBDOMAIN = ".#{Site.domain}"
|
||||
TESTING_SUBDOMAIN = ".testing.#{SUBDOMAIN}"
|
||||
PARTS = Site.domain.split('.').count
|
||||
|
||||
if Rails.env.production?
|
||||
|
@ -14,7 +15,15 @@ module Api
|
|||
|
||||
# Lista de nombres de dominios a emitir certificados
|
||||
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
|
||||
|
||||
private
|
||||
|
@ -37,24 +46,28 @@ module Api
|
|||
name.end_with?(SUBDOMAIN) && name.split('.').count == (PARTS + 1)
|
||||
end
|
||||
|
||||
# Nombres de los sitios
|
||||
def sites_names
|
||||
Site.all.order(:name).pluck(:name).map do |name|
|
||||
canonicalize name
|
||||
end.reject do |name|
|
||||
subdomain? name
|
||||
end
|
||||
# Es un dominio de prueba
|
||||
#
|
||||
# @param name [String]
|
||||
# @return [Bool]
|
||||
def testing?(name)
|
||||
name.end_with?(TESTING_SUBDOMAIN) && name.split('.').count == (PARTS + 2)
|
||||
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>]
|
||||
def alternative_names
|
||||
hostname_of(DeployAlternativeDomain.all).concat(hostname_of(DeployLocalizedDomain)).map do |name|
|
||||
canonicalize name
|
||||
end.reject do |name|
|
||||
subdomain? name
|
||||
end
|
||||
hostname_of(DeployAlternativeDomain.all)
|
||||
end
|
||||
|
||||
# Obtener todos los sitios con API habilitada, es decir formulario
|
||||
|
@ -66,10 +79,6 @@ module Api
|
|||
.or(Site.where(colaboracion_anonima: true))
|
||||
.pluck(:name).map do |name|
|
||||
"api.#{name}"
|
||||
end.map do |name|
|
||||
canonicalize name
|
||||
end.reject do |name|
|
||||
subdomain? name
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue