mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-03 20:46:28 +00:00
Handle case where a received chat message is in fact an outgoing message sent by us from an other device.
This commit is contained in:
parent
ec18035244
commit
5cf6bc3b6b
3 changed files with 21 additions and 23 deletions
|
|
@ -989,7 +989,6 @@ LinphoneReason ChatMessagePrivate::receive() {
|
|||
L_Q();
|
||||
int errorCode = 0;
|
||||
LinphoneReason reason = LinphoneReasonNone;
|
||||
bool store = false;
|
||||
|
||||
// ---------------------------------------
|
||||
// Start of message modification
|
||||
|
|
@ -1024,13 +1023,12 @@ LinphoneReason ChatMessagePrivate::receive() {
|
|||
|
||||
if (errorCode <= 0) {
|
||||
bool foundSupportContentType = false;
|
||||
for (auto it = contents.begin(); it != contents.end(); it++) {
|
||||
if (linphone_core_is_content_type_supported(chatRoom->getCore(), it->getContentType().asString().c_str())) {
|
||||
for (const auto &c : contents) {
|
||||
if (linphone_core_is_content_type_supported(chatRoom->getCore(), c.getContentType().asString().c_str())) {
|
||||
foundSupportContentType = true;
|
||||
break;
|
||||
} else {
|
||||
lError() << "Unsupported content-type: " << it->getContentType().asString();
|
||||
}
|
||||
} else
|
||||
lError() << "Unsupported content-type: " << c.getContentType().asString();
|
||||
}
|
||||
|
||||
if (!foundSupportContentType) {
|
||||
|
|
@ -1039,24 +1037,31 @@ 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)
|
||||
Address me(linphone_core_get_identity(chatRoom->getCore()));
|
||||
if (me.weakEqual(from))
|
||||
setDirection(ChatMessage::Direction::Outgoing);
|
||||
|
||||
/* Check if this is a duplicate message */
|
||||
if (chatRoom->findMessageWithDirection(q->getImdnMessageId(), q->getDirection()))
|
||||
return chatRoom->getCore()->chat_deny_code;
|
||||
|
||||
if (errorCode > 0) {
|
||||
reason = linphone_error_code_to_reason(errorCode);
|
||||
q->sendDeliveryNotification(reason);
|
||||
return reason;
|
||||
}
|
||||
|
||||
for (auto it = contents.begin(); it != contents.end(); it++) {
|
||||
if (it->getContentType() == ContentType::FileTransfer) {
|
||||
store = true;
|
||||
createFileTransferInformationsFromVndGsmaRcsFtHttpXml(it->getBodyAsString());
|
||||
} else if (it->getContentType() == ContentType::PlainText) {
|
||||
store = true;
|
||||
}
|
||||
bool messageToBeStored = false;
|
||||
for (const auto &c : contents) {
|
||||
if (c.getContentType() == ContentType::FileTransfer) {
|
||||
messageToBeStored = true;
|
||||
createFileTransferInformationsFromVndGsmaRcsFtHttpXml(c.getBodyAsString());
|
||||
} else if (c.getContentType() == ContentType::PlainText)
|
||||
messageToBeStored = true;
|
||||
}
|
||||
|
||||
if (store) {
|
||||
if (messageToBeStored)
|
||||
q->store();
|
||||
}
|
||||
|
||||
return reason;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,6 @@ public:
|
|||
std::list<std::shared_ptr<ChatMessage>> messages;
|
||||
std::list<std::shared_ptr<ChatMessage>> transientMessages;
|
||||
std::list<std::weak_ptr<ChatMessage>> weakMessages;
|
||||
std::list<LinphoneChatMessageCharacter *> receivedRttCharacters;
|
||||
std::shared_ptr<ChatMessage> pendingMessage = nullptr;
|
||||
IsComposing isComposingHandler;
|
||||
|
||||
|
|
|
|||
|
|
@ -371,12 +371,6 @@ LinphoneReason ChatRoomPrivate::messageReceived (SalOp *op, const SalMessage *sa
|
|||
LinphoneReason reason = LinphoneReasonNone;
|
||||
shared_ptr<ChatMessage> msg;
|
||||
|
||||
/* Check if this is a duplicate message */
|
||||
if ((msg = q->findMessageWithDirection(op->get_call_id(), ChatMessage::Direction::Incoming))) {
|
||||
reason = core->chat_deny_code;
|
||||
return reason;
|
||||
}
|
||||
|
||||
msg = q->createMessage();
|
||||
|
||||
Content content;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue