Add 3rd party credential invite possibility to create_room()
This is to comply with Matrix API r0.0.1
This commit is contained in:
parent
c73f76a235
commit
3e93e9e77d
@ -753,6 +753,9 @@ void matrix_api_toggle_pusher(MatrixAPI *api,
|
|||||||
* list of state events to set in the new room
|
* list of state events to set in the new room
|
||||||
* @invitees: (element-type utf8) (allow-none): list of user IDs to
|
* @invitees: (element-type utf8) (allow-none): list of user IDs to
|
||||||
* invite to the new room
|
* invite to the new room
|
||||||
|
* @invite_3pids: (element-type MatrixAPI3PidCredential) (allow-none):
|
||||||
|
* a list of 3rd party credentials to invite to the
|
||||||
|
* new room
|
||||||
* @error: return location for a #GError, or %NULL
|
* @error: return location for a #GError, or %NULL
|
||||||
*
|
*
|
||||||
* Create a new room with the given name and invite the users in
|
* Create a new room with the given name and invite the users in
|
||||||
@ -770,6 +773,7 @@ matrix_api_create_room(MatrixAPI *api,
|
|||||||
JsonNode *creation_content,
|
JsonNode *creation_content,
|
||||||
GList *initial_state,
|
GList *initial_state,
|
||||||
GList *invitees,
|
GList *invitees,
|
||||||
|
GList *invite_3pids,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
g_return_if_fail(MATRIX_IS_API(api));
|
g_return_if_fail(MATRIX_IS_API(api));
|
||||||
@ -778,7 +782,7 @@ matrix_api_create_room(MatrixAPI *api,
|
|||||||
->create_room(api, callback, user_data,
|
->create_room(api, callback, user_data,
|
||||||
preset, room_name, room_alias, topic,
|
preset, room_name, room_alias, topic,
|
||||||
visibility, creation_content,
|
visibility, creation_content,
|
||||||
initial_state, invitees,
|
initial_state, invitees, invite_3pids,
|
||||||
error);
|
error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,6 +167,7 @@ struct _MatrixAPIInterface {
|
|||||||
JsonNode *creation_content,
|
JsonNode *creation_content,
|
||||||
GList *initial_state,
|
GList *initial_state,
|
||||||
GList *invitees,
|
GList *invitees,
|
||||||
|
GList *invite_3pids,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
/* Room directory */
|
/* Room directory */
|
||||||
@ -589,6 +590,7 @@ void matrix_api_create_room(MatrixAPI *api,
|
|||||||
JsonNode *creation_content,
|
JsonNode *creation_content,
|
||||||
GList *initial_state,
|
GList *initial_state,
|
||||||
GList *invitees,
|
GList *invitees,
|
||||||
|
GList *invite_3pids,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
/* Room directory */
|
/* Room directory */
|
||||||
|
@ -870,6 +870,28 @@ add_string(gchar *str, JsonBuilder *builder)
|
|||||||
json_builder_add_string_value(builder, str);
|
json_builder_add_string_value(builder, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
JsonBuilder *builder;
|
||||||
|
GError *error;
|
||||||
|
} Add3PidCredData;
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_3pidcred(MatrixAPI3PidCredential *credential, Add3PidCredData *data)
|
||||||
|
{
|
||||||
|
JsonNode *node;
|
||||||
|
|
||||||
|
// If there is already an error set, return immediately
|
||||||
|
if (data->error) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the credentials’ JSON representation
|
||||||
|
node = matrix_api_3pid_credential_get_json_node(credential, &(data->error));
|
||||||
|
|
||||||
|
// Add it to the builder
|
||||||
|
json_builder_add_value(data->builder, node);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
i_create_room(MatrixAPI *api,
|
i_create_room(MatrixAPI *api,
|
||||||
MatrixAPICallback callback,
|
MatrixAPICallback callback,
|
||||||
@ -882,6 +904,7 @@ i_create_room(MatrixAPI *api,
|
|||||||
JsonNode *creation_content,
|
JsonNode *creation_content,
|
||||||
GList *initial_state,
|
GList *initial_state,
|
||||||
GList *invitees,
|
GList *invitees,
|
||||||
|
GList *invite_3pids,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
JsonNode *body;
|
JsonNode *body;
|
||||||
@ -910,6 +933,27 @@ i_create_room(MatrixAPI *api,
|
|||||||
json_builder_end_array(builder);
|
json_builder_end_array(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (invite_3pids) {
|
||||||
|
Add3PidCredData add_data;
|
||||||
|
|
||||||
|
add_data.builder = builder;
|
||||||
|
add_data.error = NULL;
|
||||||
|
|
||||||
|
json_builder_set_member_name(builder, "invite_3pid");
|
||||||
|
json_builder_begin_array(builder);
|
||||||
|
g_list_foreach(invite_3pids, (GFunc)add_3pidcred, &add_data);
|
||||||
|
|
||||||
|
if (add_data.error) {
|
||||||
|
g_propagate_error(error, add_data.error);
|
||||||
|
|
||||||
|
g_object_unref(builder);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
json_builder_end_array(builder);
|
||||||
|
}
|
||||||
|
|
||||||
if (room_name) {
|
if (room_name) {
|
||||||
json_builder_set_member_name(builder, "name");
|
json_builder_set_member_name(builder, "name");
|
||||||
json_builder_add_string_value(builder, room_name);
|
json_builder_add_string_value(builder, room_name);
|
||||||
|
@ -141,7 +141,7 @@ login_finished(MatrixAPI *api,
|
|||||||
"GLib SDK test room", "matrix-glib-sdk-test",
|
"GLib SDK test room", "matrix-glib-sdk-test",
|
||||||
"GLib SDK test room",
|
"GLib SDK test room",
|
||||||
MATRIX_API_ROOM_VISIBILITY_DEFAULT,
|
MATRIX_API_ROOM_VISIBILITY_DEFAULT,
|
||||||
NULL, NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL, NULL);
|
||||||
matrix_api_get_presence_list(api, NULL, NULL, user_id, NULL);
|
matrix_api_get_presence_list(api, NULL, NULL, user_id, NULL);
|
||||||
matrix_api_get_user_presence(api,
|
matrix_api_get_user_presence(api,
|
||||||
get_user_presence_finished, NULL,
|
get_user_presence_finished, NULL,
|
||||||
|
Loading…
Reference in New Issue
Block a user