Server is no longer incorrectly pulled from Gitea settings every time.

This commit is contained in:
Jamie Greunbaum 2024-05-29 20:26:07 -04:00
parent 27b5d593f6
commit 7cdd6d239d
2 changed files with 9 additions and 10 deletions

View File

@ -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 ""

View File

@ -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