0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-16 08:58:20 +02:00

modules/m_user: Add overload with phased IO: query content after type.

This commit is contained in:
Jason Volk 2019-06-27 01:32:28 -07:00
parent 0fb3f1d8ac
commit 1f1fa501d5

View file

@ -119,7 +119,7 @@ const
{
static const event::fetch::opts fopts
{
event::keys::include { "type", "content" },
event::keys::include {"type", "content"},
};
m::room::messages it
@ -148,11 +148,8 @@ const
};
size_t ret{0};
for(++it; it && it.event_idx() < b; ++it)
{
const event &event{*it};
ret += has(event);
}
for(++it; it && it.event_idx() < range.second; ++it)
ret += has(*it);
return ret;
}
@ -162,14 +159,26 @@ IRCD_MODULE_EXPORT
ircd::m::user::highlight::has(const event::idx &event_idx)
const
{
const event::fetch event
char typebuf[event::TYPE_MAX_SIZE];
const string_view type
{
event_idx, std::nothrow
m::get(std::nothrow, event_idx, "type", typebuf)
};
return event.valid?
has(event):
false;
bool ret{false};
if(type != "m.room.message")
return ret;
m::get(std::nothrow, event_idx, "content", [this, &type, &ret]
(const json::object &content)
{
m::event event;
json::get<"content"_>(event) = content;
json::get<"type"_>(event) = type;
ret = has(event);
});
return ret;
}
bool