Page MenuHomePhorge

D226.1758150823.diff
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

D226.1758150823.diff

diff --git a/src/client/actions/membership.cpp b/src/client/actions/membership.cpp
--- a/src/client/actions/membership.cpp
+++ b/src/client/actions/membership.cpp
@@ -94,7 +94,11 @@
}
m.addTrigger(CreateRoomSuccessful{r.roomId()});
- return { std::move(m), lager::noop };
+ return { std::move(m), [=](auto &&) {
+ return EffectStatus(/* succ = */ true, json{
+ {"roomId", r.roomId()},
+ });
+ } };
}
ClientResult updateClient(ClientModel m, InviteToRoomAction a)
diff --git a/src/client/client.hpp b/src/client/client.hpp
--- a/src/client/client.hpp
+++ b/src/client/client.hpp
@@ -584,6 +584,13 @@
*/
auto supportVersions() const -> lager::reader<immer::array<std::string>>;
+ /**
+ * Mark a room as a direct chat by send the m.direct account data.
+ * @return A Promise that resolves when the account data
+ * has been set, or when there is an error.
+ */
+ PromiseT addDirectRoom(std::string userId, std::string roomId) const;
+
private:
void syncForever(std::optional<int> retryTime = std::nullopt) const;
diff --git a/src/client/client.cpp b/src/client/client.cpp
--- a/src/client/client.cpp
+++ b/src/client/client.cpp
@@ -467,4 +467,22 @@
{
return clientCursor()[&ClientModel::versions];
}
+
+ auto Client::addDirectRoom(std::string userId, std::string roomId) const -> PromiseT
+ {
+ auto directRooms = this->directRoomMap();
+ if (directRooms.get().find(roomId) != nullptr) {
+ // The roomId is already in the m.direct, do nothing
+ return m_ctx.createResolvedPromise(true);
+ }
+ auto contentJson = json{};
+ for (auto i : directRooms.get()) {
+ contentJson[i.second].push_back(i.first);
+ }
+ contentJson[userId].push_back(roomId);
+ return Client::setAccountData(json{
+ {"type", "m.direct"},
+ {"content", std::move(contentJson)}
+ });
+ }
}

File Metadata

Mime Type
text/plain
Expires
Wed, Sep 17, 4:13 PM (8 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
459160
Default Alt Text
D226.1758150823.diff (2 KB)

Event Timeline