libQuotient
A Qt library for building matrix clients
reactionevent.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2019 Kitsune Ral <kitsune-ral@users.sf.net>
2 // SPDX-License-Identifier: LGPL-2.1-or-later
3 
4 #pragma once
5 
6 #include "roomevent.h"
7 #include "eventrelation.h"
8 
9 namespace Quotient {
10 
11 class QUOTIENT_API ReactionEvent
12  : public EventTemplate<
13  ReactionEvent, RoomEvent,
14  EventContent::SingleKeyValue<EventRelation, RelatesToKey>> {
15 public:
16  QUO_EVENT(ReactionEvent, "m.reaction")
17  static bool isValid(const QJsonObject& fullJson)
18  {
19  return fullJson[ContentKey][RelatesToKey][RelTypeKey].toString()
20  == EventRelation::AnnotationType;
21  }
22 
23  ReactionEvent(const QString& eventId, const QString& reactionKey)
24  : EventTemplate(EventRelation::annotate(eventId, reactionKey))
25  {}
26 
27  QString eventId() const { return content().value.eventId; }
28  QString key() const { return content().value.key; }
29 
30 private:
31  explicit ReactionEvent(const QJsonObject& json) : EventTemplate(json) {}
32 };
33 
34 } // namespace Quotient