Implement /join/$room_id
This commit is contained in:
parent
1e4a56704f
commit
6b6b3b8954
@ -62,6 +62,7 @@ matrix_http_api_register_account
|
||||
matrix_http_api_login
|
||||
matrix_http_api_initial_sync
|
||||
matrix_http_api_create_room
|
||||
matrix_http_api_join_room
|
||||
<SUBSECTION Standard>
|
||||
MatrixHTTPAPI
|
||||
MatrixHTTPAPIClass
|
||||
|
@ -85,6 +85,7 @@ matrix_http_api_matrix_api_init(MatrixAPIInterface *iface)
|
||||
iface->register_account = matrix_http_api_register_account;
|
||||
iface->initial_sync = matrix_http_api_initial_sync;
|
||||
iface->create_room = matrix_http_api_create_room;
|
||||
iface->join_room = matrix_http_api_join_room;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -418,9 +419,13 @@ matrix_http_api_send(MatrixHTTPAPI *api,
|
||||
return;
|
||||
}
|
||||
|
||||
generator = json_generator_new();
|
||||
json_generator_set_root(generator, content);
|
||||
data = json_generator_to_data(generator, &datalen);
|
||||
if (content) {
|
||||
generator = json_generator_new();
|
||||
json_generator_set_root(generator, content);
|
||||
data = json_generator_to_data(generator, &datalen);
|
||||
} else {
|
||||
data = g_strdup("");
|
||||
}
|
||||
|
||||
url = g_strdup_printf("%s%s", priv->url, path);
|
||||
g_debug("Sending %s to %s", method, url);
|
||||
@ -696,3 +701,35 @@ matrix_http_api_create_room(MatrixAPI *api,
|
||||
content,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_http_api_join_room:
|
||||
* @api: a #MatrixHTTPAPI object
|
||||
* @callback: (scope async): the function to call when the request is
|
||||
* finished
|
||||
* @user_data: user data to pass to the callback function
|
||||
* @room_id_or_alias: an alias or the ID of the room
|
||||
*
|
||||
* Perform /join/$room_id
|
||||
*/
|
||||
void
|
||||
matrix_http_api_join_room(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
gchar *room_id_or_alias)
|
||||
{
|
||||
gchar *path, *escaped_alias;
|
||||
|
||||
if (!room_id_or_alias && !*room_id_or_alias) {
|
||||
return;
|
||||
}
|
||||
|
||||
escaped_alias = soup_uri_encode(room_id_or_alias, NULL);
|
||||
path = g_strdup_printf("/join/%s", escaped_alias);
|
||||
g_free(escaped_alias);
|
||||
|
||||
matrix_http_api_send(MATRIX_HTTP_API(api),
|
||||
callback, user_data,
|
||||
"POST", path,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
@ -74,6 +74,10 @@ void matrix_http_api_create_room(MatrixAPI *api,
|
||||
gchar *room_alias,
|
||||
gboolean is_public,
|
||||
GStrv invitees);
|
||||
void matrix_http_api_join_room(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
gchar *room_id_or_alias);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user