diff --git a/src/matrix-http-api.c b/src/matrix-http-api.c index c8178a0..bc27ffd 100644 --- a/src/matrix-http-api.c +++ b/src/matrix-http-api.c @@ -583,7 +583,8 @@ _response_callback(SoupSession *session, message); } } - } else { // Not a JSON object + } else if (!JSON_NODE_HOLDS_ARRAY(content)) { + // Not a JSON object, neither an array err = g_error_new(MATRIX_API_ERROR, MATRIX_API_ERROR_BAD_RESPONSE, "Bad response (not a JSON object)"); @@ -991,6 +992,27 @@ i_join_room(MatrixAPI *api, g_free(path); } +static void +i_get_presence_list(MatrixAPI *api, + MatrixAPICallback callback, + gpointer user_data, + const gchar *user_id, + GError **error) +{ + gchar *encoded_user_id; + gchar *path; + + encoded_user_id = soup_uri_encode(user_id, NULL); + path = g_strdup_printf("presence/list/%s", encoded_user_id); + g_free(encoded_user_id); + + _send(MATRIX_HTTP_API(api), + callback, user_data, + "GET", path, NULL, NULL, + error); + g_free(path); +} + static void matrix_http_api_matrix_api_init(MatrixAPIInterface *iface) { @@ -1007,7 +1029,7 @@ matrix_http_api_matrix_api_init(MatrixAPIInterface *iface) iface->media_upload = NULL; /* Presence */ - iface->get_presence_list = NULL; + iface->get_presence_list = i_get_presence_list; iface->update_presence_list = NULL; iface->get_user_presence = NULL; iface->set_user_presence = NULL; diff --git a/src/test-client.c b/src/test-client.c index c59e357..56514f8 100644 --- a/src/test-client.c +++ b/src/test-client.c @@ -102,6 +102,7 @@ login_finished(MatrixAPI *api, JsonNode *content, gpointer data, GError *err) "GLib SDK test room", MATRIX_API_ROOM_VISIBILITY_DEFAULT, NULL, NULL, NULL, NULL); + matrix_api_get_presence_list(api, NULL, NULL, user_id, NULL); } else { g_printf("Login unsuccessful!\n"); }