Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: qxmpp-project/qxmpp
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ad540bf216b41770bdfa78255465adc1e5e0f29d
Choose a base ref
..
head repository: qxmpp-project/qxmpp
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: aa4a8dea10f14f4651a6f195ecb25078596f916b
Choose a head ref
Showing with 15 additions and 16 deletions.
  1. +15 −16 src/omemo/QXmppOmemoManager_p.cpp
31 changes: 15 additions & 16 deletions src/omemo/QXmppOmemoManager_p.cpp
Original file line number Diff line number Diff line change
@@ -991,29 +991,28 @@ QXmppTask<QXmppE2eeExtension::MessageEncryptResult> ManagerPrivate::encryptMessa
};
interface.finish(error);
} else {
const auto areDeliveryReceiptsUsed = message.isReceiptRequested() || !message.receiptId().isEmpty();
const auto deliveryReceiptsUsed = message.isReceiptRequested() || !message.receiptId().isEmpty();
const auto chatMarkerUsed = message.marker() != QXmppMessage::NoMarker;

// The following cases are covered:
// 1. Message with body (possibly including a chat state or used
// for delivery receipts) => usage of EME and fallback body
// 1. Message with body (optionally including a chat state, chat marker or used for
// delivery) => usage of EME and fallback body
// 2. Message without body
// 2.1. Message with chat state or used for delivery receipts
// => neither usage of EME nor fallback body, but hint for
// server-side storage in case of delivery receipts usage
// 2.2. Other message (e.g., trust message) => usage of EME and
// fallback body to look like a normal message
if (!message.body().isEmpty() || (message.state() == QXmppMessage::None && !areDeliveryReceiptsUsed)) {
// 2.1. Message with chat state, chat marker or used for delivery receipts
// => neither usage of EME nor fallback body, but hint for server-side storage
// in case of delivery receipts or chat marker usage
// 2.2. Other message (e.g., trust message) => usage of EME and fallback body to
// look like a normal message
if (!message.body().isEmpty() || (message.state() == QXmppMessage::None && !deliveryReceiptsUsed && !chatMarkerUsed)) {
message.setEncryptionMethod(QXmpp::Omemo2);

// A message processing hint for instructing the server to
// store the message is not needed because of the public
// fallback body.
// A message processing hint for instructing the server to store the message is
// not needed because of the public fallback body.
message.setE2eeFallbackBody(QStringLiteral("This message is encrypted with %1 but could not be decrypted").arg(message.encryptionName()));
message.setIsFallback(true);
} else if (areDeliveryReceiptsUsed) {
// A message processing hint for instructing the server to
// store the message is needed because of the missing public
// fallback body.
} else if (deliveryReceiptsUsed || chatMarkerUsed) {
// A message processing hint for instructing the server to store the message is
// needed because of the missing public fallback body.
message.addHint(QXmppMessage::Store);
}