Skip to content

Commit

Permalink
MamManager: Inject encrypted messages for other managers
Browse files Browse the repository at this point in the history
QXmppMessageDeliveryManager can now send delivery receipts for encrypted
messages as well.
  • Loading branch information
melvo committed Oct 7, 2023
1 parent 5067efe commit 0e35e81
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/client/QXmppMamManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,19 @@ QXmppTask<QXmppMamManager::RetrieveResult> QXmppMamManager::retrieveMessages(con
continue;
}

e2eeExt->decryptMessage(parseMamMessage(state.messages.at(i), Encrypted)).then(this, [this, i, queryId](auto result) {
e2eeExt->decryptMessage(parseMamMessage(state.messages.at(i), Encrypted)).then(this, [this, i, queryId](QXmppE2eeExtension::MessageDecryptResult &&result) {
auto itr = d->ongoingRequests.find(queryId.toStdString());
Q_ASSERT(itr != d->ongoingRequests.end());

auto &state = itr->second;

// store decrypted message, fallback to encrypted message
if (std::holds_alternative<QXmppMessage>(result)) {
state.processedMessages[i] = std::get<QXmppMessage>(std::move(result));
// Store the decrypted message and enable other managers to process it if the
// message could be decrypted.
// E.g., delivery receipts for encrypted messages can be sent by that.
// Otherwise, store the (original) encrypted message.
if (auto message = std::get_if<QXmppMessage>(std::move(&result))) {
state.processedMessages[i] = *message;
injectMessage(std::move(*message));
} else {
warning(QStringLiteral("Error decrypting message."));
state.processedMessages[i] = parseMamMessage(state.messages[i], Unencrypted);
Expand Down

0 comments on commit 0e35e81

Please sign in to comment.