Commit 431db458 authored by Alexander Akulich's avatar Alexander Akulich
Browse files

[KTp/Message] Direction of received message now depends on sender

If the sender is selfContact, then the direction is LocalToRemote.

REVIEW: 128867
parent 22d6c5c4
......@@ -70,7 +70,6 @@ Message::Message(const Tp::ReceivedMessage &original, const KTp::MessageContext
d->token = original.messageToken();
d->messageType = original.messageType();
d->isHistory = original.isScrollback();
d->direction = KTp::Message::RemoteToLocal;
setMainMessagePart(original.text());
......@@ -79,6 +78,22 @@ Message::Message(const Tp::ReceivedMessage &original, const KTp::MessageContext
} else {
d->senderAlias = original.senderNickname();
}
bool isLocalToRemote = false;
if (!d->sender.isNull()) {
if (context.channel()->interfaces().contains(TP_QT_IFACE_CHANNEL_INTERFACE_GROUP)) {
isLocalToRemote = d->sender->id() == context.channel()->groupSelfContact()->id();
} else {
isLocalToRemote = d->sender->id() == context.channel()->connection()->selfContact()->id();
}
}
if (isLocalToRemote) {
d->direction = KTp::Message::LocalToRemote;
} else {
d->direction = KTp::Message::RemoteToLocal;
}
}
Message::Message(const Message& other):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment