2019-03-31 22:46:48 +02:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2019 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
|
|
|
|
|
|
|
using namespace ircd;
|
|
|
|
|
|
|
|
mapi::header
|
|
|
|
IRCD_MODULE
|
|
|
|
{
|
|
|
|
"Client 14.13.1.3 :Listing Notifications"
|
|
|
|
};
|
|
|
|
|
|
|
|
ircd::resource
|
|
|
|
notifications_resource
|
|
|
|
{
|
|
|
|
"/_matrix/client/r0/notifications",
|
|
|
|
{
|
|
|
|
"(14.13.1.3) Listing Notifications"
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
conf::item<size_t>
|
|
|
|
limit_default
|
|
|
|
{
|
|
|
|
{ "name", "ircd.client.notifications.limit.default" },
|
|
|
|
{ "default", 256 }
|
|
|
|
};
|
|
|
|
|
|
|
|
resource::response
|
|
|
|
get__notifications(client &client,
|
|
|
|
const resource::request &request)
|
|
|
|
{
|
|
|
|
const string_view &from
|
|
|
|
{
|
|
|
|
request.query["from"]
|
|
|
|
};
|
|
|
|
|
|
|
|
const string_view &only
|
|
|
|
{
|
|
|
|
request.query["only"]
|
|
|
|
};
|
|
|
|
|
|
|
|
const ushort limit
|
|
|
|
{
|
|
|
|
request.query.get<ushort>("limit", size_t(limit_default))
|
|
|
|
};
|
|
|
|
|
2019-08-12 13:22:52 +02:00
|
|
|
resource::response::chunked response
|
2019-03-31 22:46:48 +02:00
|
|
|
{
|
|
|
|
client, http::OK
|
|
|
|
};
|
2019-08-12 13:22:52 +02:00
|
|
|
|
|
|
|
json::stack out
|
|
|
|
{
|
|
|
|
response.buf, response.flusher()
|
|
|
|
};
|
|
|
|
|
|
|
|
json::stack::object top
|
|
|
|
{
|
|
|
|
out
|
|
|
|
};
|
|
|
|
|
|
|
|
string_view next_token;
|
|
|
|
{
|
|
|
|
json::stack::array notifications
|
|
|
|
{
|
|
|
|
top, "notifications"
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if(next_token)
|
|
|
|
json::stack::member
|
|
|
|
{
|
|
|
|
top, "next_token", next_token
|
|
|
|
};
|
|
|
|
|
|
|
|
top.~object();
|
2020-02-12 20:30:37 +01:00
|
|
|
return std::move(response);
|
2019-03-31 22:46:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
resource::method
|
|
|
|
method_get
|
|
|
|
{
|
|
|
|
notifications_resource, "GET", get__notifications,
|
|
|
|
{
|
|
|
|
method_get.REQUIRES_AUTH
|
|
|
|
}
|
|
|
|
};
|