aboutsummaryrefslogtreecommitdiff
path: root/lib/events/eventrelation.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/events/eventrelation.h')
-rw-r--r--lib/events/eventrelation.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/events/eventrelation.h b/lib/events/eventrelation.h
new file mode 100644
index 00000000..e445ee42
--- /dev/null
+++ b/lib/events/eventrelation.h
@@ -0,0 +1,52 @@
+// SPDX-FileCopyrightText: 2022 Kitsune Ral <kitsune-ral@users.sf.net>
+// SPDX-License-Identifier: LGPL-2.1-or-later
+
+#pragma once
+
+#include "converters.h"
+
+namespace Quotient {
+
+[[maybe_unused]] constexpr auto RelatesToKey = "m.relates_to"_ls;
+constexpr auto RelTypeKey = "rel_type"_ls;
+
+struct QUOTIENT_API EventRelation {
+ using reltypeid_t = QLatin1String;
+
+ QString type;
+ QString eventId;
+ QString key = {}; // Only used for m.annotation for now
+
+ static constexpr auto ReplyType = "m.in_reply_to"_ls;
+ static constexpr auto AnnotationType = "m.annotation"_ls;
+ static constexpr auto ReplacementType = "m.replace"_ls;
+
+ static EventRelation replyTo(QString eventId)
+ {
+ return { ReplyType, std::move(eventId) };
+ }
+ static EventRelation annotate(QString eventId, QString key)
+ {
+ return { AnnotationType, std::move(eventId), std::move(key) };
+ }
+ static EventRelation replace(QString eventId)
+ {
+ return { ReplacementType, std::move(eventId) };
+ }
+
+ [[deprecated("Use ReplyRelation variable instead")]]
+ static constexpr auto Reply() { return ReplyType; }
+ [[deprecated("Use AnnotationRelation variable instead")]] //
+ static constexpr auto Annotation() { return AnnotationType; }
+ [[deprecated("Use ReplacementRelation variable instead")]] //
+ static constexpr auto Replacement() { return ReplacementType; }
+};
+
+template <>
+struct QUOTIENT_API JsonObjectConverter<EventRelation> {
+ static void dumpTo(QJsonObject& jo, const EventRelation& pod);
+ static void fillFrom(const QJsonObject& jo, EventRelation& pod);
+};
+
+}
+