0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01:00

modules/client/send_to_device: Move target into content.

modules/federation/sender: Adjust special cases.
This commit is contained in:
Jason Volk 2020-03-31 14:01:10 -07:00
parent 82e01fcc09
commit cec762de94
2 changed files with 22 additions and 6 deletions

View file

@ -146,13 +146,10 @@ try
json::iov event, content;
const json::iov::push push[]
{
// The federation sender considers the room_id property of an event
// as the "destination" and knows what to do if it's actually some
// some other string like the user::id we're targeting here.
{ event, { "room_id", target } },
{ event, { "type", "m.direct_to_device" } },
{ content, { "type", type } },
{ content, { "sender", sender } },
{ content, { "target", target } },
{ content, { "message_id", txnid } },
{ content, { "messages", out.completed() } },
};
@ -160,6 +157,7 @@ try
m::vm::copts opts;
opts.prop_mask.reset();
opts.prop_mask.set("origin");
opts.edu = true;
opts.notify_clients = false;
m::vm::eval
{

View file

@ -145,6 +145,11 @@ send_worker()
void
send(const m::event &event)
{
const auto &type
{
json::get<"type"_>(event)
};
const auto &sender
{
json::get<"sender"_>(event)
@ -155,6 +160,11 @@ send(const m::event &event)
json::get<"room_id"_>(event)
};
const json::object &content
{
json::get<"content"_>(event)
};
if(json::get<"depth"_>(event) == json::undefined_number)
return;
@ -163,8 +173,16 @@ send(const m::event &event)
return send_to_room(event, m::room::id{room_id});
// target is remote server hosting user/device
if(valid(m::id::USER, room_id))
return send_to_user(event, m::user::id{room_id});
if(type == "m.direct_to_device")
{
const json::string &target
{
content.get("target")
};
if(valid(m::id::USER, target))
return send_to_user(event, m::user::id(target));
}
// target is every remote server from every room a user is joined to.
if(valid(m::id::USER, sender))