aboutsummaryrefslogtreecommitdiff
path: root/lib/events/roomevent.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2020-03-24 22:30:53 +0100
committerKitsune Ral <Kitsune-Ral@users.sf.net>2020-03-25 22:35:23 +0100
commit5b7032e414899b5f9e8f19aec567eaed5e0fc4c2 (patch)
treea4a7c16d4a2dfe5549ddf2f5fbf0dc0742cc0bc7 /lib/events/roomevent.cpp
parentdf310485be69a5891b2dc57391854951709d474e (diff)
downloadlibquotient-5b7032e414899b5f9e8f19aec567eaed5e0fc4c2.tar.gz
libquotient-5b7032e414899b5f9e8f19aec567eaed5e0fc4c2.zip
Support of MSC1849 message editing
This is a backport of #341, as fixed by #373 and #376.
Diffstat (limited to 'lib/events/roomevent.cpp')
-rw-r--r--lib/events/roomevent.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/events/roomevent.cpp b/lib/events/roomevent.cpp
index 3d03509f..5e2d0b3c 100644
--- a/lib/events/roomevent.cpp
+++ b/lib/events/roomevent.cpp
@@ -66,6 +66,20 @@ QString RoomEvent::senderId() const
return fullJson()["sender"_ls].toString();
}
+bool RoomEvent::isReplaced() const
+{
+ return unsignedJson()["m.relations"_ls].toObject().contains("m.replace");
+}
+
+QString RoomEvent::replacedBy() const
+{
+ // clang-format off
+ return unsignedJson()["m.relations"_ls].toObject()
+ .value("m.replace").toObject()
+ .value(EventIdKeyL).toString();
+ // clang-format on
+}
+
QString RoomEvent::redactionReason() const
{
return isRedacted() ? _redactedBecause->reason() : QString{};