Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F114019
D156.1732501419.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D156.1732501419.diff
View Options
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,22 @@
});
}
+ 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) {
+ auto localEchoIt = std::find_if(
+ localEchoes.begin(), localEchoes.end(),
+ [id](const auto localEcho) {
+ return localEcho.txnId == id;
+ });
+ if (localEchoIt == localEchoes.end()) {
+ return LocalEchoDesc {};
+ }
+ return *localEchoIt;
+ });
+ }
+
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,37 @@
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
+ };
+ auto localEchoDefault = LocalEchoDesc {};
+ roomModel.localEchoes = roomModel.localEchoes.push_back(localEcho);
+
+ auto room = makeRoomWithDumbContext(roomModel);
+ REQUIRE(room.localEcho(lager::make_constant(localEcho.txnId)).make().get() == localEcho);
+ REQUIRE(room.localEcho(lager::make_constant(""s)).make().get() == localEchoDefault);
+}
+
TEST_CASE("Room::memberEventFor(), Room::memberEventByCursor", "[client][room][getter][state]")
{
auto roomModel = exampleRoomWithoutNameEvent();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 6:23 PM (8 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40001
Default Alt Text
D156.1732501419.diff (3 KB)
Attached To
Mode
D156: Add Room::localEcho and related test
Attached
Detach File
Event Timeline
Log In to Comment