0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-29 15:28:20 +02:00

modules/console: Add user presence iteration command.

This commit is contained in:
Jason Volk 2018-04-12 02:27:31 -07:00
parent 28488eb54b
commit a41420d9e5

View file

@ -2125,6 +2125,39 @@ console_cmd__user__deactivate(opt &out, const string_view &line)
return true;
}
bool
console_cmd__user__presence(opt &out, const string_view &line)
{
const params param{line, " ",
{
"user_id", "limit"
}};
const m::user user
{
param.at(0)
};
auto limit
{
param.at(1, size_t(16))
};
const m::user::room user_room{user};
user_room.for_each("m.presence", m::event::closure_bool{[&out, &limit]
(const m::event &event)
{
out << timestr(at<"origin_server_ts"_>(event) / 1000)
<< " " << at<"content"_>(event)
<< " " << at<"event_id"_>(event)
<< std::endl;
return --limit > 0;
}});
return true;
}
//
// feds
//