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

modules/m_room_tombstone: Invalidate alias cache entries for effect.

This commit is contained in:
Jason Volk 2020-11-11 15:33:48 -08:00
parent e20d1d48c4
commit aca6aae5fd
3 changed files with 61 additions and 0 deletions

View file

@ -85,6 +85,7 @@ ircd::m::matrix::module_names
"m_room_redaction",
"m_room_server_acl",
"m_room_third_party_invite",
"m_room_tombstone",
"media_media",

View file

@ -104,6 +104,7 @@ m_room_power_levels_la_SOURCES = m_room_power_levels.cc
m_room_redaction_la_SOURCES = m_room_redaction.cc
m_room_server_acl_la_SOURCES = m_room_server_acl.cc
m_room_third_party_invite_la_SOURCES = m_room_third_party_invite.cc
m_room_tombstone_la_SOURCES = m_room_tombstone.cc
m_module_LTLIBRARIES = \
m_breadcrumbs.la \
@ -135,6 +136,7 @@ m_module_LTLIBRARIES = \
m_room_redaction.la \
m_room_server_acl.la \
m_room_third_party_invite.la \
m_room_tombstone.la \
###
###############################################################################

View file

@ -0,0 +1,58 @@
// The Construct
//
// Copyright (C) The Construct Developers, Authors & Contributors
// Copyright (C) 2016-2020 Jason Volk <jason@zemos.net>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
namespace ircd::m
{
static void room_tombstone_effect_handler(const event &, vm::eval &);
extern hookfn<vm::eval &> room_tombstone_effect_hook;
}
ircd::mapi::header
IRCD_MODULE
{
"Matrix m.room.tombstone"
};
decltype(ircd::m::room_tombstone_effect_hook)
ircd::m::room_tombstone_effect_hook
{
room_tombstone_effect_handler,
{
{ "_site", "vm.effect" },
{ "type", "m.room.tombstone" },
}
};
void
ircd::m::room_tombstone_effect_handler(const m::event &event,
m::vm::eval &)
{
assert(at<"type"_>(event) == "m.room.tombstone");
const m::room room
{
at<"room_id"_>(event)
};
if(!creator(room, at<"sender"_>(event)))
return;
const m::room::aliases aliases
{
room
};
aliases.for_each([](const auto &room_alias)
{
// Invalidate the alias cache immediately so we don't have to wait a TTL
m::room::aliases::cache::del(room_alias);
return true;
});
}