libQuotient
A Qt library for building matrix clients
stickerevent.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2020 Carl Schwan <carlschwan@kde.org>
2 // SPDX-License-Identifier: LGPL-2.1-or-later
3 
4 #pragma once
5 
6 #include "roomevent.h"
7 #include "eventcontent.h"
8 
9 namespace Quotient {
10 
11 /// Sticker messages are specialised image messages that are displayed without
12 /// controls (e.g. no "download" link, or light-box view on click, as would be
13 /// displayed for for m.image events).
14 class QUOTIENT_API StickerEvent : public RoomEvent
15 {
16 public:
17  QUO_EVENT(StickerEvent, "m.sticker")
18 
19  explicit StickerEvent(const QJsonObject& obj)
20  : RoomEvent(obj)
21  , m_imageContent(
22  EventContent::ImageContent(obj["content"_L1].toObject()))
23  {}
24 
25  /// \brief A textual representation or associated description of the
26  /// sticker image.
27  ///
28  /// This could be the alt text of the original image, or a message to
29  /// accompany and further describe the sticker.
30  QUO_CONTENT_GETTER(QString, body)
31 
32  /// \brief Metadata about the image referred to in url including a
33  /// thumbnail representation.
34  const EventContent::ImageContent& image() const
35  {
36  return m_imageContent;
37  }
38 
39  /// \brief The URL to the sticker image. This must be a valid mxc:// URI.
40  QUrl url() const
41  {
42  return m_imageContent.url();
43  }
44 
45 private:
46  EventContent::ImageContent m_imageContent;
47 };
48 } // namespace Quotient