From 3cc0dbca01ea88adfd75dd12f42bc584946ff98c Mon Sep 17 00:00:00 2001 From: Fijxu Date: Thu, 17 Oct 2024 17:02:12 -0300 Subject: [PATCH] PubSub: Use external domain for pubsub feeds --- src/invidious.cr | 11 ++++++----- src/invidious/config.cr | 2 ++ src/invidious/helpers/utils.cr | 2 +- src/invidious/jobs/subscribe_to_feeds_job.cr | 2 ++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index 736573de..b66d5edb 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -67,11 +67,12 @@ REDIS_DB = Redis::PooledClient.new(unixsocket: CONFIG.redis_socket || nil, url: if REDIS_DB.ping puts "Connected to redis" end -ARCHIVE_URL = URI.parse("https://archive.org") -PUBSUB_URL = URI.parse("https://pubsubhubbub.appspot.com") -REDDIT_URL = URI.parse("https://www.reddit.com") -YT_URL = URI.parse("https://www.youtube.com") -HOST_URL = make_host_url(Kemal.config) +ARCHIVE_URL = URI.parse("https://archive.org") +PUBSUB_URL = URI.parse("https://pubsubhubbub.appspot.com") +REDDIT_URL = URI.parse("https://www.reddit.com") +YT_URL = URI.parse("https://www.youtube.com") +PUBSUB_HOST_URL = CONFIG.pubsub_domain +HOST_URL = make_host_url(Kemal.config) EXT_VIDEOP_LIST = gen_videoplayback_proxy_list() CHARS_SAFE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" diff --git a/src/invidious/config.cr b/src/invidious/config.cr index ff63f869..8f283355 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -187,6 +187,8 @@ class Config # Job to refresh tokens from a Redis compatible DB property refresh_tokens : Bool = true + property pubsub_domain : String = "" + # Materialious redirects property materialious_domain : String? diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index 3e4764c4..c95532a1 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -294,7 +294,7 @@ def subscribe_pubsub(topic, key) signature = "#{time}:#{nonce}" 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.verify" => "async", "hub.mode" => "subscribe", diff --git a/src/invidious/jobs/subscribe_to_feeds_job.cr b/src/invidious/jobs/subscribe_to_feeds_job.cr index 8584fb9c..b7e7197c 100644 --- a/src/invidious/jobs/subscribe_to_feeds_job.cr +++ b/src/invidious/jobs/subscribe_to_feeds_job.cr @@ -30,6 +30,8 @@ class Invidious::Jobs::SubscribeToFeedsJob < Invidious::Jobs::BaseJob spawn do begin response = subscribe_pubsub(ucid, hmac_key) + LOGGER.debug("SubscribeToFeedsJob: Subscribed to #{ucid}.") + LOGGER.trace("SubscribeToFeedsJob: response.body: #{response.body}") if response.status_code >= 400 LOGGER.error("SubscribeToFeedsJob: #{ucid} : #{response.body}")