summary refs log tree commit diff
path: root/src/EventAccessors.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/EventAccessors.cpp')
-rw-r--r--src/EventAccessors.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/EventAccessors.cpp b/src/EventAccessors.cpp
index ca730a75..a43d62c6 100644
--- a/src/EventAccessors.cpp
+++ b/src/EventAccessors.cpp
@@ -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,