Add support for intentional mentions

This is still a bit flaky around when to remove a mention, but it should
work in most cases. Might add a toggle in the future to disable these
though.
This commit is contained in:
Nicolas Werner 2024-03-08 18:43:59 +01:00
parent 7ec56d8df5
commit 7c2a152cfb
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
15 changed files with 242 additions and 51 deletions

View file

@ -241,6 +241,18 @@ struct EventRelations
}
};
struct EventMentions
{
template<class T>
std::optional<mtx::common::Mentions> operator()(const mtx::events::Event<T> &e)
{
if constexpr (requires { T::mentions; }) {
return e.content.mentions;
}
return std::nullopt;
}
};
struct SetEventRelations
{
mtx::common::Relations new_relations;
@ -447,6 +459,11 @@ mtx::accessors::relations(const mtx::events::collections::TimelineEvents &event)
{
return std::visit(EventRelations{}, event);
}
std::optional<mtx::common::Mentions>
mtx::accessors::mentions(const mtx::events::collections::TimelineEvents &event)
{
return std::visit(EventMentions{}, event);
}
void
mtx::accessors::set_relations(mtx::events::collections::TimelineEvents &event,