Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85970819
D319.1796330054.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None
D319.1796330054.diff
View Options
diff --git a/src/base/kazv-triggers.hpp b/src/base/kazv-triggers.hpp
--- a/src/base/kazv-triggers.hpp
+++ b/src/base/kazv-triggers.hpp
@@ -34,6 +34,7 @@
struct ReceivingRoomTimelineEvent {
Event event;
std::string roomId;
+ bool isRead;
};
struct ReceivingRoomAccountDataEvent {
diff --git a/src/client/actions/sync.cpp b/src/client/actions/sync.cpp
--- a/src/client/actions/sync.cpp
+++ b/src/client/actions/sync.cpp
@@ -87,7 +87,7 @@
intoImmer(
KazvTriggerList{},
zug::map([=](Event e) -> KazvTrigger {
- return ReceivingRoomTimelineEvent{std::move(e), id};
+ return ReceivingRoomTimelineEvent{std::move(e), id, l[id].isReadBy(e.id(), m.userId)};
}),
timelineEvents).transient());
updateRoomImpl(id, AddToTimelineAction{timelineEvents,
@@ -161,10 +161,11 @@
auto updateJoinedRoom =
[=](const auto &id, const auto &room) {
- updateSingleRoom(id, room, RoomMembership::Join);
if (room.ephemeral) {
updateRoomImpl(id, AddEphemeralAction{room.ephemeral.value().events});
}
+ // update receipt first, so isRead field of ReceivingRoomTimelineEvent can be updated
+ updateSingleRoom(id, room, RoomMembership::Join);
updateRoomNotifications(id, room);
updateRoomSummary(id, room);
};
diff --git a/src/examples/basic/main.cpp b/src/examples/basic/main.cpp
--- a/src/examples/basic/main.cpp
+++ b/src/examples/basic/main.cpp
@@ -68,7 +68,7 @@
auto watchable = eventEmitter.watchable();
watchable.after<Kazv::ReceivingRoomTimelineEvent>(
[](auto e) {
- auto [event, roomId] = e;
+ auto [event, roomId, isRead] = e;
std::cout << "\033[1;32mreceiving event " << event.id()
<< " in " << roomId
<< " from " << event.sender()
diff --git a/src/tests/client/sync-test.cpp b/src/tests/client/sync-test.cpp
--- a/src/tests/client/sync-test.cpp
+++ b/src/tests/client/sync-test.cpp
@@ -312,6 +312,53 @@
}
})"_json;
+static auto syncWithReceiptResponse = R"({
+ "next_batch": "some-example-value",
+ "rooms": {
+ "join": {
+ "!exampleroomid:example.com": {
+ "timeline": {
+ "events": [
+ {
+ "content": { "example": "foo" },
+ "event_id": "$example1:example.com",
+ "sender": "@example:example.org",
+ "origin_server_ts": 1145141919810,
+ "unsigned": { "age": 1234, "transaction_id": "some-example-txnid" },
+ "type": "m.room.message"
+ },
+ {
+ "content": { "example": "foo" },
+ "event_id": "$example2:example.com",
+ "sender": "@example:example.org",
+ "origin_server_ts": 1145141919814,
+ "unsigned": { "age": 1234, "transaction_id": "some-example-txnid" },
+ "type": "m.room.message"
+ }
+ ],
+ "limited": false
+ },
+ "ephemeral": {
+ "events": [
+ {
+ "type": "m.receipt",
+ "content": {
+ "$example1:example.com": {
+ "m.read": {
+ "@bob:example.com": {
+ "ts": 1145141919812
+ }
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+})"_json;
+
static auto addAndRemoveNotificationsJson = [](auto a, auto r) {
a["rooms"]["join"]["!exampleroomid:example.com"]["ephemeral"] = {
{"events", {
@@ -796,3 +843,18 @@
});
u.io.run();
}
+
+// TEST_CASE("Add isRead to ReceivingRoomTimelineEvent", "[client][sync]") {
+// ClientModel m = makeClient(
+// withRoom(makeRoom(
+// withRoomId("!exampleroomid:example.com")))
+// );
+// auto resp = makeResponse(
+// "Sync",
+// withResponseJsonBody(syncWithReceiptResponse)
+// | withResponseDataKV("is", "incremental")
+// );
+// auto [next, _] = processResponse(m, SyncResponse{resp});
+// auto room = next.roomList.rooms.at("!exampleroomid:example.com");
+// REQUIRE_THAT(m.nextTriggers, Catch::Matchers::Contains())
+// }
\ No newline at end of file
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 3, 12:34 PM (4 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1855503
Default Alt Text
D319.1796330054.diff (4 KB)
Attached To
Mode
D319: Add isRead field to ReceivingRoomTimelineEvent
Attached
Detach File
Event Timeline