mirror of
https://github.com/matrix-construct/construct
synced 2024-09-26 18:38:52 +02:00
modules/m_user: Add overload with phased IO: query content after type.
This commit is contained in:
parent
0fb3f1d8ac
commit
1f1fa501d5
1 changed files with 20 additions and 11 deletions
|
@ -119,7 +119,7 @@ const
|
||||||
{
|
{
|
||||||
static const event::fetch::opts fopts
|
static const event::fetch::opts fopts
|
||||||
{
|
{
|
||||||
event::keys::include { "type", "content" },
|
event::keys::include {"type", "content"},
|
||||||
};
|
};
|
||||||
|
|
||||||
m::room::messages it
|
m::room::messages it
|
||||||
|
@ -148,11 +148,8 @@ const
|
||||||
};
|
};
|
||||||
|
|
||||||
size_t ret{0};
|
size_t ret{0};
|
||||||
for(++it; it && it.event_idx() < b; ++it)
|
for(++it; it && it.event_idx() < range.second; ++it)
|
||||||
{
|
ret += has(*it);
|
||||||
const event &event{*it};
|
|
||||||
ret += has(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -162,14 +159,26 @@ IRCD_MODULE_EXPORT
|
||||||
ircd::m::user::highlight::has(const event::idx &event_idx)
|
ircd::m::user::highlight::has(const event::idx &event_idx)
|
||||||
const
|
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?
|
bool ret{false};
|
||||||
has(event):
|
if(type != "m.room.message")
|
||||||
false;
|
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
|
bool
|
||||||
|
|
Loading…
Reference in a new issue