diff --git a/src/matrix-http-api.c b/src/matrix-http-api.c index 7ca44cc..e0b705b 100644 --- a/src/matrix-http-api.c +++ b/src/matrix-http-api.c @@ -2014,6 +2014,49 @@ i_send_message_event(MatrixAPI *api, g_free(path); } +static void +i_get_room_state(MatrixAPI *api, + MatrixAPICallback callback, + gpointer user_data, + const gchar *room_id, + const gchar *event_type, + const gchar *state_key, + GError **error) +{ + gchar *encoded_room_id, *path, *encoded_event_type, *encoded_state_key; + + encoded_room_id = soup_uri_encode(room_id, NULL); + + if (event_type) { + encoded_event_type = soup_uri_encode(event_type, NULL); + + if (state_key) { + encoded_state_key = soup_uri_encode(state_key, NULL); + path = g_strdup_printf("rooms/%s/state/%s/%s", + encoded_room_id, + encoded_event_type, + encoded_state_key); + g_free(encoded_state_key); + } else { + path = g_strdup_printf("rooms/%s/state/%s", + encoded_room_id, encoded_event_type); + } + + g_free(encoded_event_type); + } else { + path = g_strdup_printf("rooms/%s/state", encoded_room_id); + } + + g_free(encoded_room_id); + + _send(MATRIX_HTTP_API(api), + callback, user_data, + CALL_API, + "GET", path, NULL, NULL, NULL, NULL, + FALSE, error); + g_free(path); +} + static void matrix_http_api_matrix_api_init(MatrixAPIInterface *iface) { @@ -2073,7 +2116,7 @@ matrix_http_api_matrix_api_init(MatrixAPIInterface *iface) iface->send_event_receipt = i_send_event_receipt; iface->redact_event = i_redact_event; iface->send_message_event = i_send_message_event; - iface->get_room_state = NULL; + iface->get_room_state = i_get_room_state; iface->send_room_event = NULL; iface->notify_room_typing = NULL; iface->sync = NULL;