From 6ab67b44beda03262ce1e17b9bf2487069bf6786 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Mon, 21 Mar 2016 10:45:27 +0000 Subject: [PATCH] Do a token_refresh if forbidden(ish) error received --- src/matrix-http-client.vala | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/matrix-http-client.vala b/src/matrix-http-client.vala index 7dc377e..56ce550 100644 --- a/src/matrix-http-client.vala +++ b/src/matrix-http-client.vala @@ -364,6 +364,15 @@ public class Matrix.HTTPClient : Matrix.HTTPAPI, Matrix.Client { if ((node = root_obj.get_member("next_batch")) != null) { _last_sync_token = node.get_string(); } + } else if ((error is Matrix.Error.M_FORBIDDEN) + || (error is Matrix.Error.M_UNKNOWN_TOKEN) + || (error is Matrix.Error.M_UNAUTHORIZED)) { + try { + token_refresh((i, ct, jc, rc, err) => { + login_finished((error == null) + || (error is Matrix.Error.NONE)); + } , null); + } catch (Matrix.Error e) {} } // It is possible that polling has been disabled while we were