Add API method for /account/whoami
This commit is contained in:
parent
71a7f29e59
commit
870ee67ab6
@ -8,6 +8,7 @@ matrix_api_get_3pids
|
||||
matrix_api_add_3pid
|
||||
matrix_api_deactivate_account
|
||||
matrix_api_change_password
|
||||
matrix_api_whoami
|
||||
matrix_api_get_profile
|
||||
matrix_api_get_avatar_url
|
||||
matrix_api_set_avatar_url
|
||||
|
@ -38,6 +38,7 @@
|
||||
* @add_3pid: the virtual function pointer to matrix_api_add_3pid()
|
||||
* @deactivate_account: the virtual function pointer to matrix_api_deactivate_account()
|
||||
* @change_password: the virtual function pointer to matrix_api_change_password()
|
||||
* @whoami: the virtual function pointer to matrix_api_whoami()
|
||||
* @get_profile: the virtual function pointer to matrix_api_get_profile()
|
||||
* @get_avatar_url: the virtual function pointer to matrix_api_get_avatar_url()
|
||||
* @set_avatar_url: the virtual function pointer to matrix_api_set_avatar_url()
|
||||
@ -231,6 +232,26 @@ matrix_api_change_password(MatrixAPI *matrix_api,
|
||||
MATRIX_API_GET_IFACE(matrix_api)->change_password(matrix_api, callback, user_data, new_password, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_api_whoami:
|
||||
* @api: a #MatrixAPI
|
||||
* @callback: (scope async): the function to call when the request is finished
|
||||
* @user_data: user data to be passed to @callback
|
||||
* @error: (nullable): a #GError, or %NULL to ignore errors
|
||||
*
|
||||
* Get the user’s Matrix ID.
|
||||
*/
|
||||
void
|
||||
matrix_api_whoami(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
{
|
||||
g_return_if_fail(api != NULL);
|
||||
|
||||
MATRIX_API_GET_IFACE(api)->whoami(api, callback, user_data, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_api_get_profile:
|
||||
* @api: a #MatrixAPI
|
||||
|
@ -66,6 +66,10 @@ struct _MatrixAPIInterface {
|
||||
gpointer user_data,
|
||||
const gchar *new_password,
|
||||
GError **error);
|
||||
void (*whoami)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void (*get_profile)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
@ -483,6 +487,10 @@ void matrix_api_change_password(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_whoami(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_get_profile(MatrixAPI *api,
|
||||
const gchar *user_id,
|
||||
MatrixAPICallback callback,
|
||||
|
@ -2155,6 +2155,15 @@ matrix_http_api_get_turn_server(MatrixAPI *matrix_api, MatrixAPICallback cb, voi
|
||||
NULL, NULL, NULL, NULL, FALSE, error);
|
||||
}
|
||||
|
||||
static void
|
||||
whoami(MatrixAPI *api, MatrixAPICallback cb, void *cb_target, GError **error)
|
||||
{
|
||||
_matrix_http_api_send(MATRIX_HTTP_API(api),
|
||||
cb, cb_target,
|
||||
CALL_TYPE_API, "GET", "account/whoami",
|
||||
NULL, NULL, NULL, NULL, FALSE, error);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_http_api_abort_pending (MatrixAPI *matrix_api)
|
||||
{
|
||||
@ -2524,6 +2533,7 @@ matrix_http_api_matrix_api_interface_init(MatrixAPIInterface * iface)
|
||||
iface->get_token = matrix_http_api_get_token;
|
||||
iface->set_token = matrix_http_api_set_token;
|
||||
iface->get_homeserver = matrix_http_api_get_homeserver;
|
||||
iface->whoami = whoami;
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user