mirror of
https://github.com/matrix-construct/construct
synced 2024-10-15 03:58:53 +02:00
modules/console: fed state command mimics fed backfill w/ eval.
This commit is contained in:
parent
12e5a3ccea
commit
287b5d6374
1 changed files with 48 additions and 4 deletions
|
@ -1746,14 +1746,22 @@ console_cmd__fed__state(const string_view &line)
|
||||||
|
|
||||||
const net::hostport remote
|
const net::hostport remote
|
||||||
{
|
{
|
||||||
token(line, ' ', 1)
|
token(line, ' ', 1, room_id.host())
|
||||||
};
|
};
|
||||||
|
|
||||||
const string_view &event_id
|
string_view event_id
|
||||||
{
|
{
|
||||||
token_count(line, ' ') >= 3? token(line, ' ', 2) : string_view{}
|
token(line, ' ', 2, {})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
string_view op
|
||||||
|
{
|
||||||
|
token(line, ' ', 3, {})
|
||||||
|
};
|
||||||
|
|
||||||
|
if(!op && event_id == "eval")
|
||||||
|
std::swap(op, event_id);
|
||||||
|
|
||||||
// Used for out.head, out.content, in.head, but in.content is dynamic
|
// Used for out.head, out.content, in.head, but in.content is dynamic
|
||||||
thread_local char buf[8_KiB];
|
thread_local char buf[8_KiB];
|
||||||
m::v1::state::opts opts;
|
m::v1::state::opts opts;
|
||||||
|
@ -1774,7 +1782,43 @@ console_cmd__fed__state(const string_view &line)
|
||||||
request
|
request
|
||||||
};
|
};
|
||||||
|
|
||||||
out << string_view{response} << std::endl;
|
const json::array &auth_chain
|
||||||
|
{
|
||||||
|
response["auth_chain"]
|
||||||
|
};
|
||||||
|
|
||||||
|
const json::array &pdus
|
||||||
|
{
|
||||||
|
response["pdus"]
|
||||||
|
};
|
||||||
|
|
||||||
|
if(op != "eval")
|
||||||
|
{
|
||||||
|
for(const json::object &event : auth_chain)
|
||||||
|
out << pretty_oneline(m::event{event}) << std::endl;
|
||||||
|
|
||||||
|
for(const json::object &event : pdus)
|
||||||
|
out << pretty_oneline(m::event{event}) << std::endl;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
m::vm::opts vmopts;
|
||||||
|
vmopts.non_conform.set(m::event::conforms::MISSING_PREV_STATE);
|
||||||
|
vmopts.non_conform.set(m::event::conforms::MISSING_MEMBERSHIP);
|
||||||
|
vmopts.prev_check_exists = false;
|
||||||
|
vmopts.notify = false;
|
||||||
|
m::vm::eval eval
|
||||||
|
{
|
||||||
|
vmopts
|
||||||
|
};
|
||||||
|
|
||||||
|
for(const json::object &event : auth_chain)
|
||||||
|
eval(event);
|
||||||
|
|
||||||
|
for(const json::object &event : pdus)
|
||||||
|
eval(event);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue