Commit 6a5190d9 authored by Benjamin REIS's avatar Benjamin REIS
Browse files

fix IMDN, do not clear imdn to be sent until we receive the 200OK

parent d9df13ba
......@@ -28,6 +28,9 @@
LINPHONE_BEGIN_NAMESPACE
class ImdnMessagePrivate : public NotificationMessagePrivate {
public:
ImdnMessage::Context getContext () {return context;}
private:
ImdnMessagePrivate (const ImdnMessage::Context &context)
: NotificationMessagePrivate(context.chatRoom, ChatMessage::Direction::Outgoing), context(context) {}
......
......@@ -86,6 +86,16 @@ void Imdn::notifyDisplay (const shared_ptr<ChatMessage> &message) {
void Imdn::onImdnMessageDelivered (const std::shared_ptr<ImdnMessage> &message) {
// If an IMDN has been successfully delivered, remove it from the list so that
// it does not get sent again
ImdnMessage::Context context = message->getPrivate()->getContext();
for (const auto &deliveredMsg : context.deliveredMessages)
deliveredMessages.remove(deliveredMsg);
for (const auto &displayedMsg : context.displayedMessages)
displayedMessages.remove(displayedMsg);
for (const auto &nonDeliveredMsg : context.nonDeliveredMessages)
nonDeliveredMessages.remove(nonDeliveredMsg);
sentImdnMessages.remove(message);
}
......@@ -205,15 +215,12 @@ void Imdn::send () {
sentImdnMessages.push_back(imdnMessage);
if (networkReachable)
imdnMessage->getPrivate()->send();
deliveredMessages.clear();
displayedMessages.clear();
}
if (!nonDeliveredMessages.empty()) {
auto imdnMessage = chatRoom->getPrivate()->createImdnMessage(nonDeliveredMessages);
sentImdnMessages.push_back(imdnMessage);
if (networkReachable)
imdnMessage->getPrivate()->send();
nonDeliveredMessages.clear();
}
}
......
......@@ -46,6 +46,8 @@ public:
MessageReason (const std::shared_ptr<ChatMessage> &message, LinphoneReason reason)
: message(message), reason(reason) {}
bool operator== (const MessageReason &other) const {return message == other.message && reason == other.reason;}
const std::shared_ptr<ChatMessage> message;
LinphoneReason reason;
};
......
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