From 22ad1b30d64b762ac5434647d6bb85782ad39c52 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Fri, 15 Jan 2016 14:04:50 +0100 Subject: [PATCH] Implement update_presence_list --- src/matrix-http-api.c | 49 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/src/matrix-http-api.c b/src/matrix-http-api.c index 0994ebe..f3bf9cc 100644 --- a/src/matrix-http-api.c +++ b/src/matrix-http-api.c @@ -1229,6 +1229,53 @@ i_media_upload(MatrixAPI *api, FALSE, error); } +static void +i_update_presence_list(MatrixAPI *api, + MatrixAPICallback callback, + gpointer user_data, + const gchar *user_id, + GList *drop_ids, + GList *invite_ids, + GError **error) +{ + gchar *encoded_user_id; + gchar *path; + JsonBuilder *builder; + JsonNode *body; + + encoded_user_id = soup_uri_encode(user_id, NULL); + path = g_strdup_printf("presence/%s/status", encoded_user_id); + g_free(encoded_user_id); + + builder = json_builder_new(); + json_builder_begin_object(builder); + + if (drop_ids) { + json_builder_set_member_name(builder, "drop"); + json_builder_begin_array(builder); + g_list_foreach(drop_ids, (GFunc)add_string, builder); + json_builder_end_array(builder); + } + + if (invite_ids) { + json_builder_set_member_name(builder, "invide"); + json_builder_begin_array(builder); + g_list_foreach(invite_ids, (GFunc)add_string, builder); + json_builder_end_array(builder); + } + + json_builder_end_object(builder); + body = json_builder_get_root(builder); + g_object_unref(builder); + + _send(MATRIX_HTTP_API(api), + callback, user_data, + CALL_API, + "POST", path, NULL, NULL, body, NULL, + FALSE, error); + g_free(path); +} + static void matrix_http_api_matrix_api_init(MatrixAPIInterface *iface) { @@ -1246,7 +1293,7 @@ matrix_http_api_matrix_api_init(MatrixAPIInterface *iface) /* Presence */ iface->get_presence_list = i_get_presence_list; - iface->update_presence_list = NULL; + iface->update_presence_list = i_update_presence_list; iface->get_user_presence = i_get_user_presence; iface->set_user_presence = NULL;