summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandr Akulich <akulichalexander@gmail.com>2016-09-08 08:20:01 (GMT)
committerAlexandr Akulich <akulichalexander@gmail.com>2016-09-20 11:03:36 (GMT)
commit431db458de1417764ecdef00974fca4c412e19f8 (patch)
treed93b9cea90f3caab8033c5c3c1e0d2f3fde62c3c
parent22d6c5c4912aa2409f3ac0c2b1541a01bd93608f (diff)
[KTp/Message] Direction of received message now depends on sender
If the sender is selfContact, then the direction is LocalToRemote. REVIEW: 128867
-rw-r--r--KTp/message.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/KTp/message.cpp b/KTp/message.cpp
index 566241e..10ceee8 100644
--- a/KTp/message.cpp
+++ b/KTp/message.cpp
@@ -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):