mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 02:02:38 +01:00
modules/console: Add event cached cmd.
This commit is contained in:
parent
d5956f47f7
commit
47bda85f3f
1 changed files with 64 additions and 0 deletions
|
@ -5591,6 +5591,70 @@ console_cmd__event__bad(opt &out, const string_view &line)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__event__cached(opt &out, const string_view &line)
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"event_id|event_idx",
|
||||
}};
|
||||
|
||||
const string_view id
|
||||
{
|
||||
param.at(0)
|
||||
};
|
||||
|
||||
static const m::event::fetch::opts opts
|
||||
{
|
||||
m::event::keys::exclude {}
|
||||
};
|
||||
|
||||
if(valid(m::id::EVENT, id))
|
||||
{
|
||||
const m::event::id event_id
|
||||
{
|
||||
id
|
||||
};
|
||||
|
||||
const bool cached
|
||||
{
|
||||
m::cached(event_id, opts)
|
||||
};
|
||||
|
||||
out << event_id << " is"
|
||||
<< (cached? " " : " not ")
|
||||
<< "cached"
|
||||
<< std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
else if(try_lex_cast<ulong>(id))
|
||||
{
|
||||
const m::event::idx event_idx
|
||||
{
|
||||
lex_cast<ulong>(id)
|
||||
};
|
||||
|
||||
const bool cached
|
||||
{
|
||||
m::cached(event_idx, opts)
|
||||
};
|
||||
|
||||
out << "idx[" << event_idx << "] is"
|
||||
<< (cached? " " : " not ")
|
||||
<< "cached"
|
||||
<< std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
else throw m::BAD_REQUEST
|
||||
{
|
||||
"Not a valid event_id or `event_idx"
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__event__erase(opt &out, const string_view &line)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue