mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-19 20:54:22 -05:00
Force refresh after receiving PubSub notification
This commit is contained in:
parent
0a8e20fd60
commit
5567e2843d
@ -2732,7 +2732,7 @@ post "/feed/webhook/:token" do |env|
|
|||||||
published = Time.parse_rfc3339(entry.xpath_node("published").not_nil!.content)
|
published = Time.parse_rfc3339(entry.xpath_node("published").not_nil!.content)
|
||||||
updated = Time.parse_rfc3339(entry.xpath_node("updated").not_nil!.content)
|
updated = Time.parse_rfc3339(entry.xpath_node("updated").not_nil!.content)
|
||||||
|
|
||||||
video = get_video(id, PG_DB, proxies, region: nil)
|
video = get_video(id, PG_DB, proxies, force_refresh: true)
|
||||||
|
|
||||||
# Deliver notifications to `/api/v1/auth/notifications`
|
# Deliver notifications to `/api/v1/auth/notifications`
|
||||||
payload = {
|
payload = {
|
||||||
|
@ -817,12 +817,12 @@ end
|
|||||||
class VideoRedirect < Exception
|
class VideoRedirect < Exception
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_video(id, db, proxies = {} of String => Array({ip: String, port: Int32}), refresh = true, region = nil)
|
def get_video(id, db, proxies = {} of String => Array({ip: String, port: Int32}), refresh = true, region = nil, force_refresh = false)
|
||||||
if db.query_one?("SELECT EXISTS (SELECT true FROM videos WHERE id = $1)", id, as: Bool) && !region
|
if db.query_one?("SELECT EXISTS (SELECT true FROM videos WHERE id = $1)", id, as: Bool) && !region
|
||||||
video = db.query_one("SELECT * FROM videos WHERE id = $1", id, as: Video)
|
video = db.query_one("SELECT * FROM videos WHERE id = $1", id, as: Video)
|
||||||
|
|
||||||
# If record was last updated over 10 minutes ago, refresh (expire param in response lasts for 6 hours)
|
# If record was last updated over 10 minutes ago, refresh (expire param in response lasts for 6 hours)
|
||||||
if refresh && Time.now - video.updated > 10.minutes
|
if (refresh && Time.now - video.updated > 10.minutes) || force_refresh
|
||||||
begin
|
begin
|
||||||
video = fetch_video(id, proxies, region)
|
video = fetch_video(id, proxies, region)
|
||||||
video_array = video.to_a
|
video_array = video.to_a
|
||||||
|
Loading…
Reference in New Issue
Block a user