From 47824233aa3ceb18290fcb53f1a44171c3af42e9 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 13 Oct 2017 11:28:20 +0200 Subject: [PATCH] Handle receiving messages in a group chat room. --- coreapi/chat.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/coreapi/chat.c b/coreapi/chat.c index b2fa26f1f..dad0c6940 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -156,11 +156,18 @@ LinphoneChatRoom *linphone_core_get_chat_room_from_uri(LinphoneCore *lc, const c } int linphone_core_message_received(LinphoneCore *lc, LinphonePrivate::SalOp *op, const SalMessage *sal_msg) { - LinphoneAddress *addr = linphone_address_new(sal_msg->from); - linphone_address_clean(addr); - LinphoneChatRoom *cr = linphone_core_get_chat_room(lc, addr); - LinphoneReason reason = L_GET_PRIVATE_FROM_C_OBJECT(cr)->messageReceived(op, sal_msg); - linphone_address_unref(addr); + LinphoneReason reason = LinphoneReasonNotAcceptable; + LinphoneChatRoom *cr = _linphone_core_find_group_chat_room(lc, op->get_from()); + if (cr) + reason = L_GET_PRIVATE_FROM_C_OBJECT(cr)->messageReceived(op, sal_msg); + else { + LinphoneAddress *addr = linphone_address_new(sal_msg->from); + linphone_address_clean(addr); + cr = linphone_core_get_chat_room(lc, addr); + if (cr) + reason = L_GET_PRIVATE_FROM_C_OBJECT(cr)->messageReceived(op, sal_msg); + linphone_address_unref(addr); + } return reason; }