mirror of
https://0xacab.org/sutty/sutty
synced 2025-02-23 23:21:48 +00:00
refactor: filtrar la lista completa
This commit is contained in:
parent
cfc016c1c6
commit
b6a2e30d03
1 changed files with 13 additions and 16 deletions
|
@ -14,7 +14,13 @@ 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.uniq
|
||||
|
||||
render json: all_names
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -38,23 +44,18 @@ module Api
|
|||
end
|
||||
|
||||
# Nombres de los sitios
|
||||
#
|
||||
# @param name [String]
|
||||
# @return [Array<String>]
|
||||
def sites_names
|
||||
Site.all.order(:name).pluck(:name).map do |name|
|
||||
canonicalize name
|
||||
end.reject do |name|
|
||||
subdomain? name
|
||||
end
|
||||
Site.all.order(:name).pluck(:name)
|
||||
end
|
||||
|
||||
# Dominios alternativos
|
||||
#
|
||||
# @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).concat(hostname_of(DeployLocalizedDomain))
|
||||
end
|
||||
|
||||
# Obtener todos los sitios con API habilitada, es decir formulario
|
||||
|
@ -66,17 +67,13 @@ 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
|
||||
|
||||
# Todos los dominios con WWW habilitado
|
||||
def www_names
|
||||
Site.where(id: DeployWww.all.pluck(:site_id)).pluck(:name).map do |name|
|
||||
canonicalize "www.#{name}"
|
||||
"www.#{name}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue