diff options
-rw-r--r-- | events/receiptevent.cpp | 7 | ||||
-rw-r--r-- | room.cpp | 6 |
2 files changed, 8 insertions, 5 deletions
diff --git a/events/receiptevent.cpp b/events/receiptevent.cpp index 3d6be9f1..646bb989 100644 --- a/events/receiptevent.cpp +++ b/events/receiptevent.cpp @@ -66,6 +66,11 @@ ReceiptEvent::ReceiptEvent(const QJsonObject& obj) } _eventsWithReceipts.push_back({eventIt.key(), receipts}); } - _unreadMessages = obj["x-qmatrixclient.unread_messages"].toBool(); + static const auto UnreadMsgsKey = + QStringLiteral("x-qmatrixclient.unread_messages"); + if (contents.contains(UnreadMsgsKey)) + _unreadMessages = contents["x-qmatrixclient.unread_messages"].toBool(); + else + _unreadMessages = obj["x-qmatrixclient.unread_messages"].toBool(); } @@ -994,14 +994,12 @@ QJsonObject Room::Private::toJson() const QJsonObject lastReadEvent; lastReadEvent.insert(q->readMarkerEventId(), receipt); + lastReadEvent.insert("x-qmatrixclient.unread_messages", + unreadMessages); QJsonObject receiptsObj; receiptsObj.insert("type", QStringLiteral("m.receipt")); receiptsObj.insert("content", lastReadEvent); - // In extension of the spec we add a hint to the receipt event - // to allow setting the unread indicator without downloading - // and analysing the timeline. - receiptsObj.insert("x-qmatrixclient.unread_messages", unreadMessages); ephemeralEvents.append(receiptsObj); } |