Commit 881d8f3d authored by Ronan's avatar Ronan
Browse files

fix(chat): chat room id must be used to create a new chat room, not just the peer address!

parent 54a672e4
......@@ -144,18 +144,17 @@ int linphone_core_message_received(LinphoneCore *lc, LinphonePrivate::SalOp *op,
localAddress = op->getTo();
}
shared_ptr<LinphonePrivate::AbstractChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(
LinphonePrivate::ChatRoomId(LinphonePrivate::IdentityAddress(peerAddress), LinphonePrivate::IdentityAddress(localAddress))
);
LinphonePrivate::ChatRoomId chatRoomId{
LinphonePrivate::IdentityAddress(peerAddress),
LinphonePrivate::IdentityAddress(localAddress)
};
shared_ptr<LinphonePrivate::AbstractChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(chatRoomId);
if (chatRoom)
reason = L_GET_PRIVATE(chatRoom)->onSipMessageReceived(op, sal_msg);
else if (!linphone_core_conference_server_enabled(lc)) {
LinphoneAddress *addr = linphone_address_new(sal_msg->from);
linphone_address_clean(addr);
LinphoneChatRoom *cr = linphone_core_get_chat_room(lc, addr);
if (cr)
reason = L_GET_PRIVATE_FROM_C_OBJECT(cr)->onSipMessageReceived(op, sal_msg);
linphone_address_unref(addr);
chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getOrCreateBasicChatRoom(chatRoomId);
if (chatRoom)
reason = L_GET_PRIVATE(chatRoom)->onSipMessageReceived(op, sal_msg);
}
return reason;
}
......
......@@ -575,7 +575,7 @@ LinphoneReason ChatMessagePrivate::receive () {
}
// Check if this is in fact an outgoing message (case where this is a message sent by us from an other device).
if (Address(chatRoom->getLocalAddress()).weakEqual(q->getFromAddress()))
if (Address(chatRoom->getLocalAddress()).weakEqual(fromAddress))
setDirection(ChatMessage::Direction::Outgoing);
// Check if this is a duplicate message.
......@@ -628,7 +628,7 @@ void ChatMessagePrivate::send () {
shared_ptr<Core> core = q->getCore();
if (lp_config_get_int(core->getCCore()->config, "sip", "chat_use_call_dialogs", 0) != 0) {
lcall = linphone_core_get_call_by_remote_address(core->getCCore(), q->getToAddress().asString().c_str());
lcall = linphone_core_get_call_by_remote_address(core->getCCore(), toAddress.asString().c_str());
if (lcall) {
shared_ptr<Call> call = L_GET_CPP_PTR_FROM_C_OBJECT(lcall);
if ((call->getState() == CallSession::State::Connected)
......@@ -641,7 +641,7 @@ void ChatMessagePrivate::send () {
op = call->getPrivate()->getOp();
string identity = linphone_core_find_best_identity(core->getCCore(), linphone_call_get_remote_address(lcall));
if (identity.empty()) {
LinphoneAddress *addr = linphone_address_new(q->getToAddress().asString().c_str());
LinphoneAddress *addr = linphone_address_new(toAddress.asString().c_str());
LinphoneProxyConfig *proxy = linphone_core_lookup_known_proxy(core->getCCore(), addr);
if (proxy) {
identity = L_GET_CPP_PTR_FROM_C_OBJECT(linphone_proxy_config_get_identity_address(proxy))->asString();
......@@ -655,7 +655,7 @@ void ChatMessagePrivate::send () {
}
if (!op) {
LinphoneAddress *peer = linphone_address_new(q->getToAddress().asString().c_str());
LinphoneAddress *peer = linphone_address_new(toAddress.asString().c_str());
/* Sending out of call */
salOp = op = new SalMessageOp(core->getCCore()->sal);
linphone_configure_op(
......@@ -665,8 +665,8 @@ void ChatMessagePrivate::send () {
op->setUserPointer(q); /* If out of call, directly store msg */
linphone_address_unref(peer);
}
op->setFrom(q->getFromAddress().asString().c_str());
op->setTo(q->getToAddress().asString().c_str());
op->setFrom(fromAddress.asString().c_str());
op->setTo(toAddress.asString().c_str());
// ---------------------------------------
// Start of message modification
......
Markdown is supported
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