Add API method for /notifications
This commit is contained in:
parent
db912dd701
commit
18b7aeb1e4
@ -61,6 +61,7 @@ matrix_api_set_presence
|
|||||||
matrix_api_list_public_rooms
|
matrix_api_list_public_rooms
|
||||||
matrix_api_get_pushers
|
matrix_api_get_pushers
|
||||||
matrix_api_update_pusher
|
matrix_api_update_pusher
|
||||||
|
matrix_api_get_notifications
|
||||||
matrix_api_get_pushrules
|
matrix_api_get_pushrules
|
||||||
matrix_api_delete_pushrule
|
matrix_api_delete_pushrule
|
||||||
matrix_api_get_pushrule
|
matrix_api_get_pushrule
|
||||||
|
@ -91,6 +91,7 @@
|
|||||||
* @list_public_rooms: the virtual function pointer to matrix_api_list_public_rooms()
|
* @list_public_rooms: the virtual function pointer to matrix_api_list_public_rooms()
|
||||||
* @get_pushers: the virtual function pointer to matrix_api_get_pushers()
|
* @get_pushers: the virtual function pointer to matrix_api_get_pushers()
|
||||||
* @update_pusher: the virtual function pointer to matrix_api_update_pusher()
|
* @update_pusher: the virtual function pointer to matrix_api_update_pusher()
|
||||||
|
* @get_notifications: the virtual function pointer to matrix_api_get_notifications()
|
||||||
* @get_pushrules: the virtual function pointer to matrix_api_get_pushrules()
|
* @get_pushrules: the virtual function pointer to matrix_api_get_pushrules()
|
||||||
* @delete_pushrule: the virtual function pointer to matrix_api_delete_pushrule()
|
* @delete_pushrule: the virtual function pointer to matrix_api_delete_pushrule()
|
||||||
* @get_pushrule: the virtual function pointer to matrix_api_get_pushrule()
|
* @get_pushrule: the virtual function pointer to matrix_api_get_pushrule()
|
||||||
@ -1670,6 +1671,33 @@ matrix_api_update_pusher(MatrixAPI *matrix_api,
|
|||||||
MATRIX_API_GET_IFACE(matrix_api)->update_pusher(matrix_api, callback, user_data, pusher, error);
|
MATRIX_API_GET_IFACE(matrix_api)->update_pusher(matrix_api, callback, user_data, pusher, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* matrix_api_get_notifications:
|
||||||
|
* @api: a #MatrixAPI
|
||||||
|
* @from_token: (nullable): Pagination token to retrieve the next set of events
|
||||||
|
* @limit: Limit on the number of events to return in the request. Set to 0 for no limit
|
||||||
|
* @filter: (nullable): Allows basic filtering of the events returned. Set it to `"highlight"` to
|
||||||
|
* return only events where the notification had the highlight tweak set.
|
||||||
|
* @callback: (scope async): a 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 notifications from the server.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
matrix_api_get_notifications(MatrixAPI *api,
|
||||||
|
const gchar *from_token,
|
||||||
|
guint limit,
|
||||||
|
const gchar *filter,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
g_return_if_fail(api != NULL);
|
||||||
|
|
||||||
|
MATRIX_API_GET_IFACE(api)->get_notifications(api, from_token, limit, filter, callback, user_data, error);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* matrix_api_get_pushrules:
|
* matrix_api_get_pushrules:
|
||||||
* @api: a #MatrixAPI
|
* @api: a #MatrixAPI
|
||||||
|
@ -399,6 +399,13 @@ struct _MatrixAPIInterface {
|
|||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
MatrixPusher *pusher,
|
MatrixPusher *pusher,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
void (*get_notifications)(MatrixAPI *api,
|
||||||
|
const gchar *from_token,
|
||||||
|
guint limit,
|
||||||
|
const gchar *filter,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
GError **error);
|
||||||
void (*get_pushrules)(MatrixAPI *api,
|
void (*get_pushrules)(MatrixAPI *api,
|
||||||
MatrixAPICallback callback,
|
MatrixAPICallback callback,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
@ -836,6 +843,13 @@ void matrix_api_update_pusher(MatrixAPI *api,
|
|||||||
MatrixAPICallback callback,
|
MatrixAPICallback callback,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
void matrix_api_get_notifications(MatrixAPI *api,
|
||||||
|
const gchar *from_token,
|
||||||
|
guint limit,
|
||||||
|
const gchar *filter,
|
||||||
|
MatrixAPICallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
GError **error);
|
||||||
void matrix_api_get_pushrules(MatrixAPI *api,
|
void matrix_api_get_pushrules(MatrixAPI *api,
|
||||||
MatrixAPICallback callback,
|
MatrixAPICallback callback,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
|
@ -2215,6 +2215,41 @@ get_joined_rooms(MatrixAPI *api, MatrixAPICallback cb, void *cb_target, GError *
|
|||||||
NULL, NULL, NULL, NULL, FALSE, error);
|
NULL, NULL, NULL, NULL, FALSE, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_notifications(MatrixAPI *api, const gchar *from_token, guint limit, const gchar *filter, MatrixAPICallback callback, gpointer user_data, GError **error)
|
||||||
|
{
|
||||||
|
GHashTable *parms = NULL;
|
||||||
|
|
||||||
|
if (from_token != NULL) {
|
||||||
|
parms = _matrix_http_api_create_query_params();
|
||||||
|
|
||||||
|
g_hash_table_replace(parms, g_strdup("from"), g_strdup(from_token));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (limit != 0) {
|
||||||
|
if (parms == NULL) {
|
||||||
|
parms = _matrix_http_api_create_query_params();
|
||||||
|
}
|
||||||
|
|
||||||
|
g_hash_table_replace(parms, g_strdup("limit"), g_strdup_printf("%u", limit));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter != NULL) {
|
||||||
|
if (parms == NULL) {
|
||||||
|
parms = _matrix_http_api_create_query_params();
|
||||||
|
}
|
||||||
|
|
||||||
|
g_hash_table_replace(parms, g_strdup("only"), g_strdup(filter));
|
||||||
|
}
|
||||||
|
|
||||||
|
_matrix_http_api_send(MATRIX_HTTP_API(api),
|
||||||
|
callback, user_data,
|
||||||
|
CALL_TYPE_API, "POST", "register",
|
||||||
|
parms, NULL, NULL, NULL, FALSE, error);
|
||||||
|
|
||||||
|
g_hash_table_unref(parms);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
matrix_http_api_abort_pending (MatrixAPI *matrix_api)
|
matrix_http_api_abort_pending (MatrixAPI *matrix_api)
|
||||||
{
|
{
|
||||||
@ -2587,6 +2622,7 @@ matrix_http_api_matrix_api_interface_init(MatrixAPIInterface * iface)
|
|||||||
iface->get_homeserver = matrix_http_api_get_homeserver;
|
iface->get_homeserver = matrix_http_api_get_homeserver;
|
||||||
iface->whoami = whoami;
|
iface->whoami = whoami;
|
||||||
iface->get_joined_rooms = get_joined_rooms;
|
iface->get_joined_rooms = get_joined_rooms;
|
||||||
|
iface->get_notifications = get_notifications;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user