PubSub: Use external domain for pubsub feeds

This commit is contained in:
Fijxu 2024-10-17 17:02:12 -03:00
parent c3e8721051
commit 3cc0dbca01
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4
4 changed files with 11 additions and 6 deletions

View file

@ -67,11 +67,12 @@ REDIS_DB = Redis::PooledClient.new(unixsocket: CONFIG.redis_socket || nil, url:
if REDIS_DB.ping if REDIS_DB.ping
puts "Connected to redis" puts "Connected to redis"
end end
ARCHIVE_URL = URI.parse("https://archive.org") ARCHIVE_URL = URI.parse("https://archive.org")
PUBSUB_URL = URI.parse("https://pubsubhubbub.appspot.com") PUBSUB_URL = URI.parse("https://pubsubhubbub.appspot.com")
REDDIT_URL = URI.parse("https://www.reddit.com") REDDIT_URL = URI.parse("https://www.reddit.com")
YT_URL = URI.parse("https://www.youtube.com") YT_URL = URI.parse("https://www.youtube.com")
HOST_URL = make_host_url(Kemal.config) PUBSUB_HOST_URL = CONFIG.pubsub_domain
HOST_URL = make_host_url(Kemal.config)
EXT_VIDEOP_LIST = gen_videoplayback_proxy_list() EXT_VIDEOP_LIST = gen_videoplayback_proxy_list()
CHARS_SAFE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" CHARS_SAFE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"

View file

@ -187,6 +187,8 @@ class Config
# Job to refresh tokens from a Redis compatible DB # Job to refresh tokens from a Redis compatible DB
property refresh_tokens : Bool = true property refresh_tokens : Bool = true
property pubsub_domain : String = ""
# Materialious redirects # Materialious redirects
property materialious_domain : String? property materialious_domain : String?

View file

@ -294,7 +294,7 @@ def subscribe_pubsub(topic, key)
signature = "#{time}:#{nonce}" signature = "#{time}:#{nonce}"
body = { body = {
"hub.callback" => "#{HOST_URL}/feed/webhook/v1:#{time}:#{nonce}:#{OpenSSL::HMAC.hexdigest(:sha1, key, signature)}", "hub.callback" => "#{PUBSUB_HOST_URL}/feed/webhook/v1:#{time}:#{nonce}:#{OpenSSL::HMAC.hexdigest(:sha1, key, signature)}",
"hub.topic" => "https://www.youtube.com/xml/feeds/videos.xml?#{topic}", "hub.topic" => "https://www.youtube.com/xml/feeds/videos.xml?#{topic}",
"hub.verify" => "async", "hub.verify" => "async",
"hub.mode" => "subscribe", "hub.mode" => "subscribe",

View file

@ -30,6 +30,8 @@ class Invidious::Jobs::SubscribeToFeedsJob < Invidious::Jobs::BaseJob
spawn do spawn do
begin begin
response = subscribe_pubsub(ucid, hmac_key) response = subscribe_pubsub(ucid, hmac_key)
LOGGER.debug("SubscribeToFeedsJob: Subscribed to #{ucid}.")
LOGGER.trace("SubscribeToFeedsJob: response.body: #{response.body}")
if response.status_code >= 400 if response.status_code >= 400
LOGGER.error("SubscribeToFeedsJob: #{ucid} : #{response.body}") LOGGER.error("SubscribeToFeedsJob: #{ucid} : #{response.body}")