summaryrefslogtreecommitdiff
path: root/src/message.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/message.cpp')
-rw-r--r--src/message.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/message.cpp b/src/message.cpp
index 389807b..54c080e 100644
--- a/src/message.cpp
+++ b/src/message.cpp
@@ -314,7 +314,10 @@ DirectMessageService::DirectMessageService(Config && c, const Server & s):
server(s),
watched(server.localState().lens<SharedState>().lens<DirectMessageThreads>().watch(
std::bind(&DirectMessageService::updateHandler, this, std::placeholders::_1)))
-{}
+{
+ server.peerList().onUpdate(std::bind(&DirectMessageService::peerWatcher, this,
+ std::placeholders::_1, std::placeholders::_2));
+}
DirectMessageService::~DirectMessageService() = default;
@@ -473,6 +476,16 @@ void DirectMessageService::updateHandler(const DirectMessageThreads & threads)
}
}
+void DirectMessageService::peerWatcher(size_t, const class Peer * peer)
+{
+ if (peer) {
+ if (auto pid = peer->identity()) {
+ syncWithPeer(server.localHead(),
+ thread(pid->finalOwner()), *peer);
+ }
+ }
+}
+
void DirectMessageService::syncWithPeer(const Head<LocalState> & head, const DirectMessageThread & thread, const Peer & peer)
{
for (const auto & msg : thread.p->head)