aboutsummaryrefslogtreecommitdiff
path: root/lib/events/roommessageevent.h
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-02-25 13:32:27 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-02-25 13:34:50 +0900
commit2213080a13a4eb472c8ac2267efcebc6f0936eb1 (patch)
treec0a14ed11401df11d070e26dd9f363c6aae935b5 /lib/events/roommessageevent.h
parent93876f06b6a1929dc757595ba4410b742402b7ab (diff)
downloadlibquotient-2213080a13a4eb472c8ac2267efcebc6f0936eb1.tar.gz
libquotient-2213080a13a4eb472c8ac2267efcebc6f0936eb1.zip
RoomMessageEvent: support m.in_reply_to (not spec-compliant yet); optimise away TextContent when not needed
1. The spec says "if you support rich replies you MUST support fallbacks" - this commit only adds dealing with event JSON but not with textual fallbacks. 2. TextContent is only created if there's something on top of plain body (an HTML body or a reply).
Diffstat (limited to 'lib/events/roommessageevent.h')
-rw-r--r--lib/events/roommessageevent.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/events/roommessageevent.h b/lib/events/roommessageevent.h
index d5b570f5..c2e075eb 100644
--- a/lib/events/roommessageevent.h
+++ b/lib/events/roommessageevent.h
@@ -92,6 +92,17 @@ namespace QMatrixClient
{
// Additional event content types
+ struct RelatesTo
+ {
+ static constexpr const char* ReplyTypeId() { return "m.in_reply_to"; }
+ QString type; // The only supported relation so far
+ QString eventId;
+ };
+ inline RelatesTo replyTo(QString eventId)
+ {
+ return { RelatesTo::ReplyTypeId(), std::move(eventId) };
+ }
+
/**
* Rich text content for m.text, m.emote, m.notice
*
@@ -101,13 +112,15 @@ namespace QMatrixClient
class TextContent: public TypedBase
{
public:
- TextContent(const QString& text, const QString& contentType);
+ TextContent(const QString& text, const QString& contentType,
+ Omittable<RelatesTo> relatesTo = none);
explicit TextContent(const QJsonObject& json);
QMimeType type() const override { return mimeType; }
QMimeType mimeType;
QString body;
+ Omittable<RelatesTo> relatesTo;
protected:
void fillJson(QJsonObject* json) const override;