Page MenuHomePhorge

D156.1732313526.diff
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

D156.1732313526.diff

diff --git a/src/client/room/room.hpp b/src/client/room/room.hpp
--- a/src/client/room/room.hpp
+++ b/src/client/room/room.hpp
@@ -178,6 +178,15 @@
*/
auto message(lager::reader<std::string> eventId) const -> lager::reader<Event>;
+ /**
+ * Get one local echo by the txnId.
+ *
+ * @param A lager::reader of the txnId.
+ *
+ * @return A lager::reader of the local echo.
+ */
+ auto localEcho(lager::reader<std::string> txnId) const -> lager::reader<LocalEchoDesc>;
+
/**
* Get the member events of heroes this room.
*
diff --git a/src/client/room/room.cpp b/src/client/room/room.cpp
--- a/src/client/room/room.cpp
+++ b/src/client/room/room.cpp
@@ -102,6 +102,14 @@
});
}
+ auto Room::localEcho(lager::reader<std::string> txnId) const -> lager::reader<LocalEchoDesc>
+ {
+ return lager::with(roomCursor()[&RoomModel::localEchoes], txnId)
+ .map([](const auto localEchoes, const auto &id) {
+ return *std::find_if(localEchoes.begin(), localEchoes.end(), [id](const auto localEcho) { return localEcho.txnId == id; });
+ });
+ }
+
auto Room::members() const -> lager::reader<immer::flex_vector<std::string>>
{
return roomCursor().map([](auto room) {
diff --git a/src/tests/client/room-test.cpp b/src/tests/client/room-test.cpp
--- a/src/tests/client/room-test.cpp
+++ b/src/tests/client/room-test.cpp
@@ -303,6 +303,35 @@
REQUIRE(room.message(lager::make_constant(messageEvent.id())).make().get() == messageEvent);
}
+TEST_CASE("Room::localEcho()", "[client][room][getter][timeline]")
+{
+ auto roomModel = exampleRoomWithoutNameEvent();
+ auto messageEvent = Event(R"({
+ "content": {
+ "body": "This is an example text message",
+ "msgtype": "m.text",
+ "format": "org.matrix.custom.html",
+ "formatted_body": "<b>This is an example text message</b>"
+ },
+ "type": "m.room.message",
+ "event_id": "$anothermessageevent:example.org",
+ "room_id": "!726s6s6q:example.com",
+ "sender": "@example:example.org",
+ "origin_server_ts": 1432735824653,
+ "unsigned": {
+ "age": 1234
+ }
+ })"_json);
+ auto localEcho = LocalEchoDesc {
+ "123456789",
+ messageEvent
+ };
+ roomModel.localEchoes = roomModel.localEchoes.push_back(localEcho);
+
+ auto room = makeRoomWithDumbContext(roomModel);
+ REQUIRE(room.localEcho(lager::make_constant(localEcho.txnId)).make().get() == localEcho);
+}
+
TEST_CASE("Room::memberEventFor(), Room::memberEventByCursor", "[client][room][getter][state]")
{
auto roomModel = exampleRoomWithoutNameEvent();

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 2:12 PM (1 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38998
Default Alt Text
D156.1732313526.diff (2 KB)

Event Timeline