summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2020-03-26 22:32:56 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2020-03-26 22:33:57 +0100
commita76a9ad65fa549d2c1650bb5a7d9a657186edc43 (patch)
tree9c502531194e94501977a57edcc6cc2c49d4f287 /src
parent3004f1ed9a3979176ec3b055c627eba88c2004f6 (diff)
Message: make sure to use owner identity
Diffstat (limited to 'src')
-rw-r--r--src/message.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/message.cpp b/src/message.cpp
index 0fcb587..b7d4bda 100644
--- a/src/message.cpp
+++ b/src/message.cpp
@@ -223,13 +223,14 @@ void DirectMessageService::handle(Context & ctx) const
auto pid = ctx.peer().identity();
if (!pid)
return;
+ auto powner = pid->finalOwner();
unique_lock lock(threadLock);
- vector<Stored<DirectMessageData>> head(DirectMessageThread::Priv::getThreadLocked(*pid).p->head);
+ vector<Stored<DirectMessageData>> head(DirectMessageThread::Priv::getThreadLocked(powner).p->head);
head.push_back(*dm);
filterAncestors(head);
- auto dmt = DirectMessageThread::Priv::updateThreadLocked(*pid, std::move(head));
+ auto dmt = DirectMessageThread::Priv::updateThreadLocked(powner, std::move(head));
lock.unlock();
@@ -246,7 +247,7 @@ void DirectMessageService::onUpdate(ThreadWatcher w)
DirectMessageThread DirectMessageService::thread(const Identity & peer)
{
scoped_lock lock(threadLock);
- return DirectMessageThread::Priv::getThreadLocked(peer);
+ return DirectMessageThread::Priv::getThreadLocked(peer.finalOwner());
}
DirectMessage DirectMessageService::send(const Identity & from, const Peer & peer, const string & text)
@@ -254,17 +255,18 @@ DirectMessage DirectMessageService::send(const Identity & from, const Peer & pee
auto pid = peer.identity();
if (!pid)
throw std::runtime_error("Peer without known identity");
+ auto powner = pid->finalOwner();
scoped_lock lock(threadLock);
auto msg = from.ref()->storage().store(DirectMessageData {
- .prev = DirectMessageThread::Priv::getThreadLocked(*pid).p->head,
- .from = from,
+ .prev = DirectMessageThread::Priv::getThreadLocked(powner).p->head,
+ .from = from.finalOwner(),
.time = ZonedTime::now(),
.text = text,
});
- DirectMessageThread::Priv::updateThreadLocked(*pid, { msg });
+ DirectMessageThread::Priv::updateThreadLocked(powner, { msg });
peer.send(myUUID, msg.ref());
return DirectMessage(new DirectMessage::Priv {