diff options
author | Ave <ave@ave.zone> | 2021-02-10 21:13:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-10 20:13:53 +0000 |
commit | 2fcd5b8f901034980616e5f719750c48f37a332f (patch) | |
tree | 02cc62ef5de83e64b8100e8aa9ae4f8f8750339a | |
parent | 40ef6d51b2830f215c8a14b412dc25b51494476f (diff) | |
download | purple-matrix-2fcd5b8f901034980616e5f719750c48f37a332f.tar.gz |
matrix-api: use a non-fatal error code on HTTP 429 and >500 (#113)
This, in turn, allows bitlbee to automatically reattempt to reconnect.
-rw-r--r-- | matrix-api.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/matrix-api.c b/matrix-api.c index 2eae2a9..0884c93 100644 --- a/matrix-api.c +++ b/matrix-api.c @@ -66,6 +66,7 @@ void matrix_api_bad_response(MatrixConnectionData *ma, gpointer user_data, JsonObject *json_obj; const gchar *errcode = NULL, *error = NULL; gchar *error_message; + PurpleConnectionError error_reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR; if(json_root != NULL) { json_obj = matrix_json_node_get_object(json_root); @@ -81,8 +82,13 @@ void matrix_api_bad_response(MatrixConnectionData *ma, gpointer user_data, _("Error from home server"), http_response_code); } + /* Use a non-fatal error reason on HTTP 429 and 500 to allow auto-reconnection */ + if (http_response_code == 429 || http_response_code > 500) { + error_reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; + } + purple_connection_error_reason(ma->pc, - PURPLE_CONNECTION_ERROR_OTHER_ERROR, + error_reason, error_message); g_free(error_message); |