aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-07-30 23:25:01 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-07-30 23:25:01 +0200
commit2975b435f1ae198187183b883b5e666c7659e8fc (patch)
tree77d6d1b630e73ad9d981eff47698c118b0a77128
parenta2e8575f8b843eb9534c42b9c2864923a0329119 (diff)
downloadlibquotient-2975b435f1ae198187183b883b5e666c7659e8fc.tar.gz
libquotient-2975b435f1ae198187183b883b5e666c7659e8fc.zip
Room::setReadReceipt()
-rw-r--r--lib/room.cpp9
-rw-r--r--lib/room.h7
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index c7f29b6d..649b1ed2 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -765,6 +765,15 @@ Room::Changes Room::Private::setFullyReadMarker(const QString& eventId)
return changes;
}
+void Room::setReadReceipt(const QString& atEventId)
+{
+ d->setLastReadReceipt(localUser(), historyEdge(),
+ { atEventId, QDateTime::currentDateTime() });
+ connection()->callApi<PostReceiptJob>(BackgroundRequest, id(),
+ QStringLiteral("m.read"),
+ QUrl::toPercentEncoding(atEventId));
+}
+
void Room::Private::markMessagesAsRead(const rev_iter_t &upToMarker)
{
if (upToMarker < q->fullyReadMarker()) {
diff --git a/lib/room.h b/lib/room.h
index 9ef553df..afe223c5 100644
--- a/lib/room.h
+++ b/lib/room.h
@@ -626,7 +626,12 @@ public Q_SLOTS:
void downloadFile(const QString& eventId, const QUrl& localFilename = {});
void cancelFileTransfer(const QString& id);
- /// Mark all messages in the room as read
+ //! \brief Set a given event as last read and post a read receipt on it
+ //!
+ //! Does nothing if the event is behind the current read receipt.
+ //! \sa lastReadReceipt, markMessagesAsRead, markAllMessagesAsRead
+ void setReadReceipt(const QString& atEventId);
+ //! Put the fully-read marker at the latest message in the room
void markAllMessagesAsRead();
/// Switch the room's version (aka upgrade)