mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 02:02:38 +01:00
modules/federation/sender: Hack other send targets carried in event's room_id.
This commit is contained in:
parent
2db5278eb2
commit
190662f16d
1 changed files with 40 additions and 2 deletions
|
@ -22,6 +22,7 @@ static void recv();
|
|||
static void recv_worker();
|
||||
ctx::dock recv_action;
|
||||
|
||||
static void send(const m::event &, const m::user::id &user_id);
|
||||
static void send(const m::event &, const m::room::id &room_id);
|
||||
static void send(const m::event &);
|
||||
static void send_worker();
|
||||
|
@ -126,8 +127,11 @@ send(const m::event &event)
|
|||
if(json::get<"depth"_>(event) == json::undefined_number)
|
||||
return;
|
||||
|
||||
if(room_id)
|
||||
return send(event, room_id);
|
||||
if(valid(m::id::ROOM, room_id))
|
||||
return send(event, m::room::id{room_id});
|
||||
|
||||
if(valid(m::id::USER, room_id))
|
||||
return send(event, m::user::id{room_id});
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -166,6 +170,40 @@ send(const m::event &event,
|
|||
});
|
||||
}
|
||||
|
||||
void
|
||||
send(const m::event &event,
|
||||
const m::user::id &user_id)
|
||||
{
|
||||
const string_view &remote
|
||||
{
|
||||
user_id.host()
|
||||
};
|
||||
|
||||
if(my_host(remote))
|
||||
return;
|
||||
|
||||
auto it{nodes.lower_bound(remote)};
|
||||
if(it == end(nodes) || it->first != remote)
|
||||
{
|
||||
if(server::errmsg(remote))
|
||||
return;
|
||||
|
||||
it = nodes.emplace_hint(it, remote, remote);
|
||||
}
|
||||
|
||||
auto &node{it->second};
|
||||
if(node.err)
|
||||
return;
|
||||
|
||||
auto unit
|
||||
{
|
||||
std::make_shared<struct unit>(event)
|
||||
};
|
||||
|
||||
node.push(std::move(unit));
|
||||
node.flush();
|
||||
}
|
||||
|
||||
void
|
||||
node::push(std::shared_ptr<unit> su)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue