Make HTTP API to send the access token automatically
This commit is contained in:
		| @@ -430,6 +430,12 @@ response_callback(SoupSession *session, | ||||
|     } | ||||
| } | ||||
|  | ||||
| static void | ||||
| update_query_params(gchar *key, gchar *value, SoupURI *uri) | ||||
| { | ||||
|     soup_uri_set_query_from_fields(uri, key, value, NULL); | ||||
| } | ||||
|  | ||||
| static void | ||||
| matrix_http_api_send(MatrixHTTPAPI *api, | ||||
|                      MatrixAPICallback callback, | ||||
| @@ -472,6 +478,15 @@ matrix_http_api_send(MatrixHTTPAPI *api, | ||||
|     } | ||||
|  | ||||
|     uri = soup_uri_new_with_base(priv->uri, path); | ||||
|  | ||||
|     if (params) { | ||||
|         g_hash_table_foreach(params, (GHFunc)update_query_params, uri); | ||||
|     } | ||||
|  | ||||
|     if (priv->token) { | ||||
|         update_query_params("access_token", priv->token, uri); | ||||
|     } | ||||
|  | ||||
|     url = soup_uri_to_string(uri, FALSE); | ||||
|     soup_uri_free(uri); | ||||
|     g_debug("Sending %s to %s", method, url); | ||||
|   | ||||
| @@ -95,6 +95,12 @@ main(int argc, char *argv[]) | ||||
|  | ||||
|     g_info("Starting up: %s with %s:%s", url, user, password); | ||||
|  | ||||
|     /* | ||||
|      * [ ] register | ||||
|      * [X] login | ||||
|      * [ ] create_room | ||||
|      * [ ] join_room | ||||
|      */ | ||||
|     api = matrix_http_api_new(url, NULL); | ||||
|     params = matrix_http_api_gen_parameters( | ||||
|             "user", user, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user