Implement list_room_messages

This commit is contained in:
Gergely Polonkai 2016-01-15 16:31:02 +01:00
parent f5abd813c8
commit d20e9a9060

View File

@ -1860,6 +1860,51 @@ i_list_room_members(MatrixAPI *api,
g_free(path); g_free(path);
} }
static void
i_list_room_messages(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *room_id,
const gchar *from_token,
MatrixAPIEventDirection direction,
guint limit,
GError **error)
{
gchar *encoded_room_id, *path;
GHashTable *params;
encoded_room_id = soup_uri_encode(room_id, NULL);
path = g_strdup_printf("rooms/%s/messages", encoded_room_id);
g_free(encoded_room_id);
params = create_query_params();
g_hash_table_replace(params, "from", g_strdup(from_token));
switch (direction) {
case MATRIX_API_EVENT_DIRECTION_BACKWARD:
g_hash_table_replace(params, "dir", g_strdup("b"));
break;
case MATRIX_API_EVENT_DIRECTION_FORWARD:
g_hash_table_replace(params, "dir", g_strdup("f"));
break;
}
if (limit != 0) {
g_hash_table_replace(params, "limit", g_strdup_printf("%u", limit));
}
_send(MATRIX_HTTP_API(api),
callback, user_data,
CALL_API,
"GET", path, params, NULL, NULL, NULL,
FALSE, error);
g_free(path);
}
static void static void
matrix_http_api_matrix_api_init(MatrixAPIInterface *iface) matrix_http_api_matrix_api_init(MatrixAPIInterface *iface)
{ {
@ -1915,7 +1960,7 @@ matrix_http_api_matrix_api_init(MatrixAPIInterface *iface)
iface->get_event_context = i_get_event_context; iface->get_event_context = i_get_event_context;
iface->initial_sync_room = i_initial_sync_room; iface->initial_sync_room = i_initial_sync_room;
iface->list_room_members = i_list_room_members; iface->list_room_members = i_list_room_members;
iface->list_room_messages = NULL; iface->list_room_messages = i_list_room_messages;
iface->send_event_receipt = NULL; iface->send_event_receipt = NULL;
iface->redact_event = NULL; iface->redact_event = NULL;
iface->send_message_event = NULL; iface->send_message_event = NULL;