5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-06-02 04:34:16 +00:00

centralizar la forma en que se obtienen los hostnames

relacionado con !50
This commit is contained in:
f 2022-04-26 16:46:48 -03:00
parent 47a74b5848
commit 298fd5bed1
2 changed files with 24 additions and 22 deletions

View file

@ -26,7 +26,7 @@ class UriCollectionJob < PeriodicJob
name = 'host|uri'
beginning = beginning_of_interval
hostnames.each do |host|
site.hostnames.each do |host|
break if stop?
uris.each do |uri|
@ -102,26 +102,6 @@ class UriCollectionJob < PeriodicJob
@destination ||= site.deploys.find_by(type: 'DeployLocal').destination
end
# TODO: Cambiar al mergear origin-referer
#
# @return [Array]
def hostnames
@hostnames ||= site.deploys.map do |deploy|
case deploy
when DeployLocal
site.hostname
when DeployWww
deploy.fqdn
when DeployAlternativeDomain
deploy.hostname.dup.tap do |h|
h.replace(h.end_with?('.') ? h[0..-2] : "#{h}.#{Site.domain}")
end
when DeployHiddenService
deploy.onion
end
end.compact
end
# Recolecta todas las URIs menos imágenes
#
# @return [Array]

View file

@ -101,6 +101,26 @@ class Site < ApplicationRecord
"https://#{hostname}#{slash ? '/' : ''}"
end
# TODO: Cambiar al mergear origin-referer
#
# @return [Array]
def hostnames
@hostnames ||= deploys.map do |deploy|
case deploy
when DeployLocal
hostname
when DeployWww
deploy.fqdn
when DeployAlternativeDomain
deploy.hostname.dup.tap do |h|
h.replace(h.end_with?('.') ? h[0..-2] : "#{h}.#{Site.domain}")
end
when DeployHiddenService
deploy.onion
end
end.compact
end
# Obtiene los dominios alternativos
#
# @return Array
@ -123,7 +143,9 @@ class Site < ApplicationRecord
#
# @return Array
def urls(slash: true)
alternative_urls(slash: slash) << url(slash: slash)
@urls ||= hostnames.map do |h|
"https://#{h}#{slash ? '/' : ''}"
end
end
def invitade?(usuarie)