mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2026-03-03 04:40:04 +00:00
Fix logic of this shit again
This commit is contained in:
@@ -119,7 +119,13 @@ class CompanionStatus
|
|||||||
client = HTTP::Client.new(companion.private_url, tls: tls)
|
client = HTTP::Client.new(companion.private_url, tls: tls)
|
||||||
client.connect_timeout = 10.seconds
|
client.connect_timeout = 10.seconds
|
||||||
|
|
||||||
response = client.get(CONFIG.check_backends_path)
|
begin
|
||||||
|
response = client.get(CONFIG.check_backends_path)
|
||||||
|
rescue
|
||||||
|
@companions[index].status = Status::Down
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if response.status_code == 200
|
if response.status_code == 200
|
||||||
if response.content_type == "application/json"
|
if response.content_type == "application/json"
|
||||||
body = response.body
|
body = response.body
|
||||||
|
|||||||
@@ -181,11 +181,13 @@ module Invidious::Routes::BeforeAll::Companion
|
|||||||
else
|
else
|
||||||
# Set cookie if there is no cookie
|
# Set cookie if there is no cookie
|
||||||
if !env.request.cookies.has_key?("PREFS")
|
if !env.request.cookies.has_key?("PREFS")
|
||||||
|
current_companion = get_companion(preferences)
|
||||||
current_companion = self.find_available_companion(env, host, nil, companion_status, preferences)
|
current_companion = self.find_available_companion(env, host, nil, companion_status, preferences)
|
||||||
if current_companion
|
if current_companion
|
||||||
self.set_companion(env, preferences, host, current_companion)
|
self.set_companion(env, preferences, host, current_companion)
|
||||||
else
|
else
|
||||||
return ""
|
current_companion = rand(c_size)
|
||||||
|
self.set_companion(env, preferences, host, current_companion)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ module Invidious::Routes::PreferencesRoute
|
|||||||
|
|
||||||
def self.update(env)
|
def self.update(env)
|
||||||
locale = env.get("preferences").as(Preferences).locale
|
locale = env.get("preferences").as(Preferences).locale
|
||||||
|
preferences = env.get("preferences").as(Preferences)
|
||||||
referer = get_referer(env)
|
referer = get_referer(env)
|
||||||
|
|
||||||
video_loop = env.params.body["video_loop"]?.try &.as(String)
|
video_loop = env.params.body["video_loop"]?.try &.as(String)
|
||||||
@@ -176,6 +177,12 @@ module Invidious::Routes::PreferencesRoute
|
|||||||
show_community_backends ||= "off"
|
show_community_backends ||= "off"
|
||||||
show_community_backends = show_community_backends == "on"
|
show_community_backends = show_community_backends == "on"
|
||||||
|
|
||||||
|
current_companion = preferences.current_companion
|
||||||
|
|
||||||
|
search_privacy = env.params.body["search_privacy"]?.try &.as(String)
|
||||||
|
search_privacy ||= "off"
|
||||||
|
search_privacy = search_privacy == "on"
|
||||||
|
|
||||||
# Convert to JSON and back again to take advantage of converters used for compatibility
|
# Convert to JSON and back again to take advantage of converters used for compatibility
|
||||||
preferences = Preferences.from_json({
|
preferences = Preferences.from_json({
|
||||||
annotations: annotations,
|
annotations: annotations,
|
||||||
@@ -216,6 +223,8 @@ module Invidious::Routes::PreferencesRoute
|
|||||||
hidden_channels: hidden_channels,
|
hidden_channels: hidden_channels,
|
||||||
default_trending_type: default_trending_type,
|
default_trending_type: default_trending_type,
|
||||||
show_community_backends: show_community_backends,
|
show_community_backends: show_community_backends,
|
||||||
|
current_companion: current_companion,
|
||||||
|
search_privacy: search_privacy,
|
||||||
}.to_json)
|
}.to_json)
|
||||||
|
|
||||||
if user = env.get? "user"
|
if user = env.get? "user"
|
||||||
|
|||||||
Reference in New Issue
Block a user