From a6ba98ecc6409a2133bbbd592bf76f96af789770 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Wed, 13 Jan 2016 09:55:33 +0100 Subject: [PATCH] Implement leave_room --- src/matrix-http-api.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/matrix-http-api.c b/src/matrix-http-api.c index 71a86cb..15171ad 100644 --- a/src/matrix-http-api.c +++ b/src/matrix-http-api.c @@ -930,6 +930,26 @@ i_event_stream(MatrixAPI *api, err); } +static void +i_leave_room(MatrixAPI *api, + MatrixAPICallback callback, + gpointer user_data, + const gchar *room_id, + GError **error) +{ + gchar *encoded_room_id, *path; + + encoded_room_id = soup_uri_encode(room_id, NULL); + path = g_strdup_printf("rooms/%s/leave", encoded_room_id); + g_free(encoded_room_id); + + _send(MATRIX_HTTP_API(api), + callback, user_data, + "POST", path, NULL, NULL, + error); + g_free(path); +} + static void matrix_http_api_matrix_api_init(MatrixAPIInterface *iface) { @@ -943,4 +963,5 @@ matrix_http_api_matrix_api_init(MatrixAPIInterface *iface) iface->create_room = i_create_room; iface->initial_sync = i_initial_sync; iface->event_stream = i_event_stream; + iface->leave_room = i_leave_room; }