From 7cdd6d239d1319a409c8d8841f3e3038fbed1077 Mon Sep 17 00:00:00 2001 From: Jamie Greunbaum Date: Wed, 29 May 2024 20:26:07 -0400 Subject: [PATCH] Server is no longer incorrectly pulled from Gitea settings every time. --- Scripts/server_api.gd | 13 ++++++------- Scripts/server_gitea_api.gd | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Scripts/server_api.gd b/Scripts/server_api.gd index 18e92dd..06a09fc 100644 --- a/Scripts/server_api.gd +++ b/Scripts/server_api.gd @@ -22,19 +22,18 @@ func _send_form_data(data:Dictionary, map_name:String, bug_position:Vector3, bug static func _create_new_server_api() -> BugbotServerAPI: - match ProjectSettings.get_setting("bugbot/reporting/bug_report_platform", -1): + match ProjectSettings.get_setting("bugbot/reporting/bug_report_platform", BugReportPlatform.BUGZILLA): BugReportPlatform.BUGZILLA: return BugbotServerAPI.new() BugReportPlatform.GITEA: return BugbotServerGiteaAPI.new() BugReportPlatform.JIRA: return BugbotServerAPI.new() return BugbotServerAPI.new() -func __connect_to_server(http_client:HTTPClient, default_server:String) -> int: - var full_server : String = ProjectSettings.get_setting("bugbot/reporting/gitea/server", default_server) - var server_and_port : PackedStringArray = full_server.rsplit(":",true,1) - var server : String = server_and_port[0] +func __connect_to_server(http_client:HTTPClient, server:String) -> int: + var server_and_port : PackedStringArray = server.rsplit(":",true,1) + var server_domain : String = server_and_port[0] var port : int = int(server_and_port[1]) - http_client.connect_to_host(server if port > 0 else full_server, port if port > 0 else -1) + http_client.connect_to_host(server_domain if port > 0 else server, port if port > 0 else -1) while http_client.get_status() == HTTPClient.STATUS_CONNECTING or http_client.get_status() == HTTPClient.STATUS_RESOLVING: http_client.poll() @@ -47,7 +46,7 @@ func __get_http_client_chunk_response(http_client:HTTPClient) -> String: http_client.poll() var chunk : PackedByteArray = http_client.read_response_body_chunk() if chunk.size() > 0: - response_body = response_body + chunk + response_body += chunk return response_body.get_string_from_utf8() return "" diff --git a/Scripts/server_gitea_api.gd b/Scripts/server_gitea_api.gd index a37a806..827b940 100644 --- a/Scripts/server_gitea_api.gd +++ b/Scripts/server_gitea_api.gd @@ -23,7 +23,7 @@ const RESOLVED_TAG : StringName = &"Status/Resolved" func __return_list_of_bugs_thread(map_name:String, callback:Callable) -> void: var http_client : HTTPClient = HTTPClient.new() - if __connect_to_server(http_client, DEFAULT_SERVER) != HTTPClient.STATUS_CONNECTED: + if __connect_to_server(http_client, ProjectSettings.get_setting("bugbot/reporting/gitea/server", DEFAULT_SERVER)) != HTTPClient.STATUS_CONNECTED: printerr("Could not connect to server.") return @@ -61,7 +61,7 @@ func __return_list_of_bugs_thread(map_name:String, callback:Callable) -> void: func __prepare_form_thread(callback:Callable) -> void: var http_client : HTTPClient = HTTPClient.new() - if __connect_to_server(http_client, DEFAULT_SERVER) != HTTPClient.STATUS_CONNECTED: + if __connect_to_server(http_client, ProjectSettings.get_setting("bugbot/reporting/gitea/server", DEFAULT_SERVER)) != HTTPClient.STATUS_CONNECTED: printerr("Could not connect to server.") return @@ -118,7 +118,7 @@ func __prepare_form_thread(callback:Callable) -> void: func __send_form_data_thread(data:Dictionary, map_name:String, bug_position:Vector3, bug_normal:Vector3, callback:Callable) -> void: var http_client : HTTPClient = HTTPClient.new() - if __connect_to_server(http_client, DEFAULT_SERVER) != HTTPClient.STATUS_CONNECTED: + if __connect_to_server(http_client, ProjectSettings.get_setting("bugbot/reporting/gitea/server", DEFAULT_SERVER)) != HTTPClient.STATUS_CONNECTED: printerr("Could not connect to server.") return