0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 08:42:34 +01:00

modules/client/sync/to_device: Implement to_device event polylog sync.

This commit is contained in:
Jason Volk 2019-02-22 14:45:07 -08:00
parent 456a3fcc49
commit cdb0ed443d

View file

@ -49,8 +49,66 @@ ircd::m::sync::to_device_polylog(data &data)
data.out, "events"
};
const m::room::state &state
const m::room &user_room
{
data.user_state
data.user_room
};
m::room::messages it
{
user_room
};
for(; it; ++it)
{
const auto &event_idx(it.event_idx());
if(!apropos(data, event_idx))
break;
bool relevant(false);
m::get(std::nothrow, event_idx, "type", [&relevant]
(const string_view &type)
{
relevant = type == "ircd.to_device";
});
if(!relevant)
continue;
m::get(std::nothrow, event_idx, "content", [&data, &array]
(const json::object &content)
{
data.commit();
json::stack::object event
{
array
};
json::stack::member
{
event, "sender", unquote(content.at("sender"))
};
json::stack::member
{
event, "type", unquote(content.at("type"))
};
json::stack::object content_
{
event, "content"
};
json::stack::member
{
content_, "device_id", unquote(content.at("device_id"))
};
for(const auto &[property, value] : json::object(content.at("content")))
json::stack::member
{
content_, property, value
};
});
}
}