mirror of
https://github.com/matrix-construct/construct
synced 2024-11-17 23:40:57 +01:00
modules/client/sync/to_device: Implement to_device event polylog sync.
This commit is contained in:
parent
456a3fcc49
commit
cdb0ed443d
1 changed files with 60 additions and 2 deletions
|
@ -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
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue