]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_xmpp: Ensure the connection filter is available.
authorJoshua Colp <jcolp@digium.com>
Sun, 22 Oct 2017 22:32:20 +0000 (19:32 -0300)
committerJoshua Colp <jcolp@digium.com>
Wed, 25 Oct 2017 16:23:44 +0000 (11:23 -0500)
Users of the API that res_xmpp provides expect that a
filter be available on the client at all times. When
OAuth authentication support was added this requirement
was not maintained.

This change merely moves the OAuth authentication to
after the filter is created, ensuring users of res_xmpp
can add things to the filter as needed.

ASTERISK-27346

Change-Id: I4ac474afe220e833288ff574e32e2b9a23394886
(cherry picked from commit 07e17fd04ffcf204400898660a4c118666596d5d)

res/res_xmpp.c

index f5bac130abad1a3596daa601d92ebda419dbb8e2..8e3b47b038b3730a1ecc05076b96d86faa4b55a9 100644 (file)
@@ -3654,13 +3654,6 @@ static int xmpp_client_reconnect(struct ast_xmpp_client *client)
                return -1;
        }
 
-       if (!ast_strlen_zero(clientcfg->refresh_token)) {
-               ast_debug(2, "Obtaining OAuth access token for client '%s'\n", client->name);
-               if (fetch_access_token(clientcfg)) {
-                       return -1;
-               }
-       }
-
        ast_xmpp_client_disconnect(client);
 
        client->timeout = 50;
@@ -3671,6 +3664,13 @@ static int xmpp_client_reconnect(struct ast_xmpp_client *client)
                return -1;
        }
 
+       if (!ast_strlen_zero(clientcfg->refresh_token)) {
+               ast_debug(2, "Obtaining OAuth access token for client '%s'\n", client->name);
+               if (fetch_access_token(clientcfg)) {
+                       return -1;
+               }
+       }
+
        /* If it's a component connect to user otherwise connect to server */
        res = iks_connect_via(client->parser, S_OR(clientcfg->server, client->jid->server), clientcfg->port,
                              ast_test_flag(&clientcfg->flags, XMPP_COMPONENT) ? clientcfg->user : client->jid->server);