From 527c8e4beb72edc05d2fd33b1115174fc168d58a Mon Sep 17 00:00:00 2001 From: Kenneth Jiang Date: Tue, 17 Oct 2023 04:11:20 -0700 Subject: [PATCH] Further decouple the tunnel request from the response --- backend/app/views/tunnelv2_views.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/backend/app/views/tunnelv2_views.py b/backend/app/views/tunnelv2_views.py index 9fa1afb55..d5f3ff816 100644 --- a/backend/app/views/tunnelv2_views.py +++ b/backend/app/views/tunnelv2_views.py @@ -70,7 +70,11 @@

Either your printer is offline, or the Obico plugin version is - lower than {min_version}. + lower than the minimum versions: +

@@ -277,8 +281,6 @@ def retrieve_klipper_host_info(octoprinttunnel): @condition(etag_func=fetch_static_etag) def _octoprint_http_tunnel(request, octoprinttunnel): user = octoprinttunnel.printer.user - - min_version = MIN_SUPPORTED_VERSION[get_agent_name(octoprinttunnel)].public version = octoprinttunnel.printer.agent_version or '0.0' if user.tunnel_usage_over_cap(): @@ -289,12 +291,12 @@ def _octoprint_http_tunnel(request, octoprinttunnel): # if plugin is disconnected, halt if channels.num_ws_connections(channels.octo_group_name(octoprinttunnel.printer.id)) < 1: return HttpResponse( - NOT_CONNECTED_HTML.format(min_version=min_version), + NOT_CONNECTED_HTML, status=NOT_CONNECTED_STATUS_CODE) if not is_plugin_version_supported(get_agent_name(octoprinttunnel), version): return HttpResponse( - NOT_CONNECTED_HTML.format(min_version=min_version), + NOT_CONNECTED_HTML, status=NOT_CONNECTED_STATUS_CODE) method = request.method.lower() @@ -370,7 +372,7 @@ def _tunnel_http_req_and_wait_for_resp(octoprinttunnel, path, method, req_header if data is None: # request timed out return HttpResponse( - NOT_CONNECTED_HTML.format(min_version=min_version), + NOT_CONNECTED_HTML, status=TIMED_OUT_STATUS_CODE) content_type = data['response']['headers'].get('Content-Type') or None