From a76a9ad65fa549d2c1650bb5a7d9a657186edc43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Thu, 26 Mar 2020 22:32:56 +0100 Subject: Message: make sure to use owner identity --- src/message.cpp | 14 ++++++++------ 1 file 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> head(DirectMessageThread::Priv::getThreadLocked(*pid).p->head); + vector> 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 { -- cgit v1.2.3