feat(backends): redirect to another backend if one is unavailable
Some checks failed
Invidious CI / build (push) Has been cancelled
Some checks failed
Invidious CI / build (push) Has been cancelled
Only works with cookies for now. Support for numbered backends will be added later since it requires some black magic.
This commit is contained in:
parent
e13800e859
commit
ad95f0e2c0
4 changed files with 22 additions and 2 deletions
|
@ -528,5 +528,6 @@
|
|||
"username_required_field": "Username is a required field",
|
||||
"username_empty": "Username cannot be empty",
|
||||
"username_is_the_same": "This is your username, use another one",
|
||||
"username_taken": "Username is already taken, use another one"
|
||||
"username_taken": "Username is already taken, use another one",
|
||||
"backend_unavailable": "The backend you selected is unavailable. You have been redirected to the next one"
|
||||
}
|
||||
|
|
|
@ -518,5 +518,6 @@
|
|||
"carousel_go_to": "Ir a la diapositiva `x`",
|
||||
"footer_contact_url": "Contactar al Administrador",
|
||||
"preferences_preload_label": "Precargar datos del vídeo: ",
|
||||
"Filipino (auto-generated)": "Filipino (generado automáticamente)"
|
||||
"Filipino (auto-generated)": "Filipino (generado automáticamente)",
|
||||
"backend_unavailable": "El backend seleccionado no está disponible. Has sido redireccionado al siguiente"
|
||||
}
|
||||
|
|
|
@ -48,6 +48,17 @@ module Invidious::Routes::BeforeAll
|
|||
env.response.cookies[CONFIG.server_id_cookie_name] = Invidious::User::Cookies.server_id(host, current_companion)
|
||||
end
|
||||
|
||||
companion_status = BackendInfo.get_status
|
||||
|
||||
if companion_status[current_companion] != 2
|
||||
alive_companion = companion_status.index(2)
|
||||
if alive_companion
|
||||
env.set "companion_switched", true
|
||||
current_companion = alive_companion
|
||||
env.response.cookies[CONFIG.server_id_cookie_name] = Invidious::User::Cookies.server_id(host, current_companion)
|
||||
end
|
||||
end
|
||||
|
||||
env.set "current_companion", current_companion
|
||||
|
||||
if host.split(".").last == "i2p"
|
||||
|
|
|
@ -112,6 +112,7 @@
|
|||
domain = env.get?("using_domain")
|
||||
scheme = env.get("scheme")
|
||||
status = BackendInfo.get_status
|
||||
companion_switched = env.get?("companion_switched")
|
||||
%>
|
||||
<div class="h-box" style="margin-bottom: 10px;">
|
||||
<b>Switch Backend:</b>
|
||||
|
@ -149,6 +150,12 @@
|
|||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if companion_switched %>
|
||||
<div class="h-box">
|
||||
<p><%= translate(locale, "backend_unavailable") %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if CONFIG.banner %>
|
||||
<div class="h-box">
|
||||
<h3><%= CONFIG.banner %></h3>
|
||||
|
|
Loading…
Add table
Reference in a new issue