mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
modules/client/rooms/messages: Add filtered messages pagination.
This commit is contained in:
parent
ea73700103
commit
3ec5df018a
1 changed files with 25 additions and 3 deletions
|
@ -32,11 +32,28 @@ get__messages(client &client,
|
|||
request
|
||||
};
|
||||
|
||||
const string_view &filter
|
||||
const auto &filter_query
|
||||
{
|
||||
request.query["filter"]
|
||||
};
|
||||
|
||||
const unique_buffer<mutable_buffer> filter_buf
|
||||
{
|
||||
size(filter_query) * 3
|
||||
};
|
||||
|
||||
const json::object &filter_json
|
||||
{
|
||||
url::decode(filter_query, filter_buf)
|
||||
};
|
||||
|
||||
const m::room_event_filter filter
|
||||
{
|
||||
filter_json.has("filter_json")?
|
||||
json::object{filter_json.get("filter_json")}:
|
||||
filter_json
|
||||
};
|
||||
|
||||
const m::room room
|
||||
{
|
||||
room_id
|
||||
|
@ -91,8 +108,13 @@ get__messages(client &client,
|
|||
break;
|
||||
}
|
||||
|
||||
messages.append(event);
|
||||
if(++count >= page.limit)
|
||||
if(empty(filter_json) || match(filter, event))
|
||||
{
|
||||
messages.append(event);
|
||||
++count;
|
||||
}
|
||||
|
||||
if(count >= page.limit)
|
||||
{
|
||||
if(page.dir == 'b')
|
||||
end = at<"event_id"_>(event);
|
||||
|
|
Loading…
Reference in a new issue