libQuotient
A Qt library for building matrix clients
eventrelation.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2022 Kitsune Ral <kitsune-ral@users.sf.net>
2 // SPDX-License-Identifier: LGPL-2.1-or-later
3 
4 #pragma once
5 
6 #include <Quotient/converters.h>
7 
8 namespace Quotient {
9 
10 constexpr inline auto RelatesToKey = "m.relates_to"_ls;
11 constexpr inline auto RelTypeKey = "rel_type"_ls;
12 
13 struct QUOTIENT_API EventRelation {
14  using reltypeid_t = QLatin1String;
15 
16  QString type;
17  QString eventId;
18  QString key = {}; // Only used for m.annotation for now
19 
20  static constexpr auto ReplyType = "m.in_reply_to"_ls;
21  static constexpr auto AnnotationType = "m.annotation"_ls;
22  static constexpr auto ReplacementType = "m.replace"_ls;
23 
24  static EventRelation replyTo(QString eventId)
25  {
26  return { ReplyType, std::move(eventId) };
27  }
28  static EventRelation annotate(QString eventId, QString key)
29  {
30  return { AnnotationType, std::move(eventId), std::move(key) };
31  }
32  static EventRelation replace(QString eventId)
33  {
34  return { ReplacementType, std::move(eventId) };
35  }
36 };
37 
38 template <>
39 struct QUOTIENT_API JsonObjectConverter<EventRelation> {
40  static void dumpTo(QJsonObject& jo, const EventRelation& pod);
41  static void fillFrom(const QJsonObject& jo, EventRelation& pod);
42 };
43 
44 } // namespace Quotient