summary refs log tree commit diff
path: root/src/Cache.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-06-14 00:35:28 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2022-06-14 00:35:28 +0200
commit6e1fec1e635039a7060c369ca03e0f970f9e449c (patch)
tree56f0fd1730a5544eac9ac66a07d1c63ab6758760 /src/Cache.cpp
parentMerge pull request #1093 from syldrathecat/msginput-cursor-rect (diff)
downloadnheko-6e1fec1e635039a7060c369ca03e0f970f9e449c.tar.xz
Update hidden read receipts MSC
Diffstat (limited to 'src/Cache.cpp')
-rw-r--r--src/Cache.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp
index c651b61b..90c04e61 100644
--- a/src/Cache.cpp
+++ b/src/Cache.cpp
@@ -1728,8 +1728,17 @@ Cache::saveState(const mtx::responses::Sync &res)
                 Receipts receipts;
 
                 for (const auto &[event_id, userReceipts] : receiptsEv->content.receipts) {
-                    for (const auto &[user_id, receipt] : userReceipts.users) {
-                        receipts[event_id][user_id] = receipt.ts;
+                    if (auto r = userReceipts.find(mtx::events::ephemeral::Receipt::Read);
+                        r != userReceipts.end()) {
+                        for (const auto &[user_id, receipt] : r->second.users) {
+                            receipts[event_id][user_id] = receipt.ts;
+                        }
+                    }
+                    if (userReceipts.count(mtx::events::ephemeral::Receipt::ReadPrivate)) {
+                        auto ts = userReceipts.at(mtx::events::ephemeral::Receipt::ReadPrivate)
+                                    .users.at(local_user_id);
+                        if (ts.ts != 0)
+                            receipts[event_id][local_user_id] = ts.ts;
                     }
                 }
                 updateReadReceipt(txn, room.first, receipts);
@@ -1761,12 +1770,15 @@ Cache::saveState(const mtx::responses::Sync &res)
                 std::vector<QString> receipts;
 
                 for (const auto &[event_id, userReceipts] : receiptsEv->content.receipts) {
-                    for (const auto &[user_id, receipt] : userReceipts.users) {
-                        (void)receipt;
-
-                        if (user_id != local_user_id) {
-                            receipts.push_back(QString::fromStdString(event_id));
-                            break;
+                    if (auto r = userReceipts.find(mtx::events::ephemeral::Receipt::Read);
+                        r != userReceipts.end()) {
+                        for (const auto &[user_id, receipt] : r->second.users) {
+                            (void)receipt;
+
+                            if (user_id != local_user_id) {
+                                receipts.push_back(QString::fromStdString(event_id));
+                                break;
+                            }
                         }
                     }
                 }