ircd:Ⓜ️:event::append: Add conf item to exclude org.matrix.dummy_event fake read receipts.

This commit is contained in:
Jason Volk 2023-02-21 18:36:58 -08:00
parent 6b62fb1fe6
commit 9cb3bf2c28
1 changed files with 25 additions and 0 deletions

View File

@ -12,6 +12,7 @@ namespace ircd::m
{
extern const event::keys::exclude event_append_exclude_keys;
extern const event::keys event_append_default_keys;
extern conf::item<std::string> event_append_exclude_types;
extern conf::item<bool> event_append_info;
extern log::log event_append_log;
}
@ -30,6 +31,13 @@ ircd::m::event_append_info
{ "persist", false },
};
decltype(ircd::m::event_append_exclude_types)
ircd::m::event_append_exclude_types
{
{ "name", "ircd.m.event.append.exclude.types" },
{ "default", "org.matrix.dummy_event" },
};
/// Default event property mask of keys which we strip from the event sent
/// to the client. This mask is applied only if the caller of event::append{}
/// did not supply their mask to apply. It is also inferior to the user's
@ -104,6 +112,23 @@ ircd::m::event::append::append(json::stack::object &object,
if(opts.event_filter && !m::match(*opts.event_filter, event))
return false;
const auto &not_types
{
event_append_exclude_types
};
if(!opts.event_filter && token_exists(not_types, ' ', json::get<"type"_>(event)))
{
log::debug
{
log, "Not sending event %s because type '%s' excluded by configuration.",
string_view{event.event_id},
json::get<"type"_>(event),
};
return false;
}
if(opts.query_visible && opts.user_id && !visible(event, *opts.user_id))
{
log::debug