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

ircd:Ⓜ️ Hook ctor rewrites local m::id's with my_host(); update affected hooks.

This commit is contained in:
Jason Volk 2018-03-03 02:38:05 -08:00
parent 7eff71b9a3
commit 90e3b90775
5 changed files with 57 additions and 22 deletions

View file

@ -579,10 +579,47 @@ ircd::m::hook::hook(decltype(function) function,
ircd::m::hook::hook(const json::members &members,
decltype(function) function)
try
:_feature
:_feature{[&members]() -> json::strung
{
members
}
const ctx::critical_assertion ca;
std::vector<json::member> copy
{
begin(members), end(members)
};
for(auto &member : copy) switch(hash(member.first))
{
case hash("room_id"):
{
// Rewrite the room_id if the supplied input has no hostname
if(valid_local_only(id::ROOM, member.second))
{
assert(my_host());
thread_local char buf[256];
member.second = id::room { buf, member.second, my_host() };
}
validate(id::ROOM, member.second);
continue;
}
case hash("sender"):
{
// Rewrite the sender if the supplied input has no hostname
if(valid_local_only(id::USER, member.second))
{
assert(my_host());
thread_local char buf[256];
member.second = id::user { buf, member.second, my_host() };
}
validate(id::USER, member.second);
continue;
}
}
return { copy.data(), copy.data() + copy.size() };
}()}
,feature
{
_feature

View file

@ -205,11 +205,10 @@ const m::hook
_create_alias_room
{
{
{ "_site", "vm notify" },
{ "room_id", "!ircd:zemos.net" },
{ "type", "m.room.create" },
{ "_site", "vm notify" },
{ "room_id", "!ircd" },
{ "type", "m.room.create" },
},
[](const m::event &)
{
m::create(alias_room_id, m::me.user_id);

View file

@ -96,11 +96,10 @@ _create_public_room(const m::event &)
const m::hook
_create_public_hook
{
_create_public_room,
{
{ "_site", "vm notify" },
{ "room_id", "!ircd:zemos.net" },
{ "type", "m.room.create" },
},
_create_public_room
{ "_site", "vm notify" },
{ "room_id", "!ircd" },
{ "type", "m.room.create" },
}
};

View file

@ -308,9 +308,9 @@ _first_user_hook
{
_first_user_registered,
{
{ "_site", "vm notify" },
{ "room_id", "!users:zemos.net" },
{ "type", "ircd.user" },
{ "_site", "vm notify" },
{ "room_id", "!users" },
{ "type", "ircd.user" },
},
};

View file

@ -136,9 +136,9 @@ _update_conf_hook
{
_update_conf,
{
{ "_site", "vm notify" },
{ "room_id", "!control:zemos.net" },
{ "type", "m.room.message" },
{ "_site", "vm notify" },
{ "room_id", "!control" },
{ "type", "m.room.message" },
{ "content",
{
{ "msgtype", "m.text" }
@ -150,9 +150,9 @@ const m::hook
_create_conf_hook
{
{
{ "_site", "vm notify" },
{ "room_id", "!ircd:zemos.net" },
{ "type", "m.room.create" },
{ "_site", "vm notify" },
{ "room_id", "!ircd" },
{ "type", "m.room.create" },
},
[](const m::event &)
{