Invidious is an alternative front-end to YouTube
Prepare to create a 'Channel' module
Samantaz Fox8e8ca4fcc5cf
diff --git a/src/invidious.cr b/src/invidious.crindex 2874cc71..5064f0b8 100644--- a/src/invidious.cr+++ b/src/invidious.cr@@ -48,6 +48,13 @@ require "./invidious/search/*"require "./invidious/routes/**"require "./invidious/jobs/**"+# Declare the base namespace for invidious+module Invidious+end++# Simple alias to make code easier to read+alias IV = Invidious+CONFIG = Config.loadHMAC_KEY = CONFIG.hmac_key || Random::Secure.hex(32)@@ -172,7 +179,7 @@ if CONFIG.popular_enabledInvidious::Jobs.register Invidious::Jobs::PullPopularVideosJob.new(PG_DB)end-CONNECTION_CHANNEL = Channel({Bool, Channel(PQ::Notification)}).new(32)+CONNECTION_CHANNEL = ::Channel({Bool, ::Channel(PQ::Notification)}).new(32)Invidious::Jobs.register Invidious::Jobs::NotificationJob.new(CONNECTION_CHANNEL, CONFIG.database_url)Invidious::Jobs.register Invidious::Jobs::ClearExpiredItemsJob.newdiff --git a/src/invidious/jobs/notification_job.cr b/src/invidious/jobs/notification_job.crindex 2f525e08..b445107b 100644--- a/src/invidious/jobs/notification_job.cr+++ b/src/invidious/jobs/notification_job.cr@@ -1,12 +1,12 @@class Invidious::Jobs::NotificationJob < Invidious::Jobs::BaseJob- private getter connection_channel : Channel({Bool, Channel(PQ::Notification)})+ private getter connection_channel : ::Channel({Bool, ::Channel(PQ::Notification)})private getter pg_url : URIdef initialize(@connection_channel, @pg_url)enddef begin- connections = [] of Channel(PQ::Notification)+ connections = [] of ::Channel(PQ::Notification)PG.connect_listen(pg_url, "notifications") { |event| connections.each(&.send(event)) }diff --git a/src/invidious/jobs/refresh_channels_job.cr b/src/invidious/jobs/refresh_channels_job.crindex 92681408..80812a63 100644--- a/src/invidious/jobs/refresh_channels_job.cr+++ b/src/invidious/jobs/refresh_channels_job.cr@@ -8,7 +8,7 @@ class Invidious::Jobs::RefreshChannelsJob < Invidious::Jobs::BaseJobmax_fibers = CONFIG.channel_threadslim_fibers = max_fibersactive_fibers = 0- active_channel = Channel(Bool).new+ active_channel = ::Channel(Bool).newbackoff = 2.minutesloop dodiff --git a/src/invidious/jobs/refresh_feeds_job.cr b/src/invidious/jobs/refresh_feeds_job.crindex 4b52c959..4f8130df 100644--- a/src/invidious/jobs/refresh_feeds_job.cr+++ b/src/invidious/jobs/refresh_feeds_job.cr@@ -7,7 +7,7 @@ class Invidious::Jobs::RefreshFeedsJob < Invidious::Jobs::BaseJobdef beginmax_fibers = CONFIG.feed_threadsactive_fibers = 0- active_channel = Channel(Bool).new+ active_channel = ::Channel(Bool).newloop dodb.query("SELECT email FROM users WHERE feed_needs_update = true OR feed_needs_update IS NULL") do |rs|diff --git a/src/invidious/jobs/subscribe_to_feeds_job.cr b/src/invidious/jobs/subscribe_to_feeds_job.crindex a431a48a..8584fb9c 100644--- a/src/invidious/jobs/subscribe_to_feeds_job.cr+++ b/src/invidious/jobs/subscribe_to_feeds_job.cr@@ -12,7 +12,7 @@ class Invidious::Jobs::SubscribeToFeedsJob < Invidious::Jobs::BaseJobendactive_fibers = 0- active_channel = Channel(Bool).new+ active_channel = ::Channel(Bool).newloop dodb.query_all("SELECT id FROM channels WHERE CURRENT_TIMESTAMP - subscribed > interval '4 days' OR subscribed IS NULL") do |rs|