mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-03-16.git
synced 2024-08-15 00:53:18 +00:00
Update pubsub to support lease_seconds
This commit is contained in:
parent
8e884fe115
commit
7425700009
5 changed files with 19 additions and 13 deletions
|
@ -4,7 +4,7 @@ class InvidiousChannel
|
|||
author: String,
|
||||
updated: Time,
|
||||
deleted: Bool,
|
||||
subscribed: {type: Bool, default: false},
|
||||
subscribed: Time?,
|
||||
})
|
||||
end
|
||||
|
||||
|
@ -186,7 +186,7 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil)
|
|||
db.exec("DELETE FROM channel_videos * WHERE NOT id = ANY ('{#{ids.map { |id| %("#{id}") }.join(",")}}') AND ucid = $1", ucid)
|
||||
end
|
||||
|
||||
channel = InvidiousChannel.new(ucid, author, Time.now, false, false)
|
||||
channel = InvidiousChannel.new(ucid, author, Time.now, false, nil)
|
||||
|
||||
return channel
|
||||
end
|
||||
|
@ -198,12 +198,12 @@ def subscribe_pubsub(ucid, key, config)
|
|||
host_url = make_host_url(Kemal.config.ssl || config.https_only, config.domain)
|
||||
|
||||
body = {
|
||||
"hub.callback" => "#{host_url}/feed/webhook",
|
||||
"hub.topic" => "https://www.youtube.com/feeds/videos.xml?channel_id=#{ucid}",
|
||||
"hub.verify" => "async",
|
||||
"hub.mode" => "subscribe",
|
||||
"hub.verify_token" => "#{time}:#{OpenSSL::HMAC.hexdigest(:sha1, key, time)}",
|
||||
"hub.secret" => key.to_s,
|
||||
"hub.callback" => "#{host_url}/feed/webhook/#{time}:#{OpenSSL::HMAC.hexdigest(:sha1, key, time)}",
|
||||
"hub.topic" => "https://www.youtube.com/feeds/videos.xml?channel_id=#{ucid}",
|
||||
"hub.verify" => "async",
|
||||
"hub.mode" => "subscribe",
|
||||
"hub.lease_seconds" => "432000",
|
||||
"hub.secret" => key.to_s,
|
||||
}
|
||||
|
||||
return client.post("/subscribe", form: body)
|
||||
|
|
|
@ -157,7 +157,7 @@ def subscribe_to_feeds(db, logger, key, config)
|
|||
if config.use_pubsub_feeds
|
||||
spawn do
|
||||
loop do
|
||||
db.query_all("SELECT id FROM channels WHERE subscribed = false") do |rs|
|
||||
db.query_all("SELECT id FROM channels WHERE CURRENT_TIMESTAMP - subscribed > '4 days'") do |rs|
|
||||
ucid = rs.read(String)
|
||||
response = subscribe_pubsub(ucid, key, config)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue