Commit 0a8c7836 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Never send aggregated IMDN messages if it is deactivated, send multiple messages instead.

parent 064b3c30
...@@ -212,20 +212,48 @@ void Imdn::send () { ...@@ -212,20 +212,48 @@ void Imdn::send () {
return; return;
if (!deliveredMessages.empty() || !displayedMessages.empty()) { if (!deliveredMessages.empty() || !displayedMessages.empty()) {
auto imdnMessage = chatRoom->getPrivate()->createImdnMessage(deliveredMessages, displayedMessages); if (aggregationEnabled()) {
sentImdnMessages.push_back(imdnMessage); auto imdnMessage = chatRoom->getPrivate()->createImdnMessage(deliveredMessages, displayedMessages);
imdnMessage->getPrivate()->send(); sentImdnMessages.push_back(imdnMessage);
if (!aggregationEnabled()) { imdnMessage->getPrivate()->send();
} else {
list<shared_ptr<ImdnMessage>> imdnMessages;
for (const auto &message : deliveredMessages) {
list<shared_ptr<ChatMessage>> l;
l.push_back(message);
imdnMessages.push_back(chatRoom->getPrivate()->createImdnMessage(l, list<shared_ptr<ChatMessage>>()));
}
for (const auto &message : displayedMessages) {
list<shared_ptr<ChatMessage>> l;
l.push_back(message);
imdnMessages.push_back(chatRoom->getPrivate()->createImdnMessage(list<shared_ptr<ChatMessage>>(), l));
}
for (const auto &message : imdnMessages) {
sentImdnMessages.push_back(message);
message->getPrivate()->send();
}
deliveredMessages.clear(); deliveredMessages.clear();
displayedMessages.clear(); displayedMessages.clear();
} }
} }
if (!nonDeliveredMessages.empty()) { if (!nonDeliveredMessages.empty()) {
auto imdnMessage = chatRoom->getPrivate()->createImdnMessage(nonDeliveredMessages); if (aggregationEnabled()) {
sentImdnMessages.push_back(imdnMessage); auto imdnMessage = chatRoom->getPrivate()->createImdnMessage(nonDeliveredMessages);
imdnMessage->getPrivate()->send(); sentImdnMessages.push_back(imdnMessage);
if (!aggregationEnabled()) imdnMessage->getPrivate()->send();
} else {
list<shared_ptr<ImdnMessage>> imdnMessages;
for (const auto &message : nonDeliveredMessages) {
list<MessageReason> l;
l.push_back(message);
imdnMessages.push_back(chatRoom->getPrivate()->createImdnMessage(l));
}
for (const auto &message : imdnMessages) {
sentImdnMessages.push_back(message);
message->getPrivate()->send();
}
nonDeliveredMessages.clear(); nonDeliveredMessages.clear();
}
} }
} }
......
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