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 | [[deprecated("Use a two-argument constructor instead" )]] // REMOVEME: 0.8 |
24 | explicit ReactionEvent(const EventRelation& er) |
25 | : EventTemplate(er) |
26 | {} |
27 | ReactionEvent(const QString& eventId, const QString& reactionKey) |
28 | : EventTemplate(EventRelation::annotate(eventId, key: reactionKey)) |
29 | {} |
30 | |
31 | [[deprecated("Use eventId(), key(), or content().value instead" )]] |
32 | EventRelation relation() const { return content().value; } |
33 | QString eventId() const { return content().value.eventId; } |
34 | QString key() const { return content().value.key; } |
35 | |
36 | private: |
37 | explicit ReactionEvent(const QJsonObject& json) : EventTemplate(json) {} |
38 | }; |
39 | |
40 | } // namespace Quotient |
41 | |