summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2019-04-22 11:15:19 -0500
committerOmar Roth <omarroth@hotmail.com>2019-04-22 11:15:19 -0500
commit5567e2843d0abc1871b0a83b530d83e722a80ee2 (patch)
tree0f287035e1b743a1934b70f756e3ef15f329a4db
parent0a8e20fd60d65e2d38acda4e09435190fa1f2e89 (diff)
downloadinvidious-5567e2843d0abc1871b0a83b530d83e722a80ee2.tar.gz
invidious-5567e2843d0abc1871b0a83b530d83e722a80ee2.tar.bz2
invidious-5567e2843d0abc1871b0a83b530d83e722a80ee2.zip
Force refresh after receiving PubSub notification
-rw-r--r--src/invidious.cr2
-rw-r--r--src/invidious/videos.cr4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index ac9b1320..4a15602e 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -2732,7 +2732,7 @@ post "/feed/webhook/:token" do |env|
published = Time.parse_rfc3339(entry.xpath_node("published").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`
payload = {
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index 1da9fd0e..b039436a 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -817,12 +817,12 @@ end
class VideoRedirect < Exception
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
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 refresh && Time.now - video.updated > 10.minutes
+ if (refresh && Time.now - video.updated > 10.minutes) || force_refresh
begin
video = fetch_video(id, proxies, region)
video_array = video.to_a