QXmpp::Messages::PrepareBodyOnly Struct

struct QXmpp::Messages::PrepareBodyOnly
Header: #include <QXmppMessages.h>

Detailed Description

Hook run synchronously when an outgoing message is encrypted for recipients of an encryption protecting only the body (QXmpp::E2ee::ContentEncryption::BodyOnly, e.g. OMEMO 0), at most once per message. It is not run if no such recipient is left after the provider selected the devices.

Handlers adapt the message for those recipients (BodyOnlyMessage::message()), e.g. replace elements by a fallback in the body, and decide which elements may be sent in the clear (BodyOnlyMessage::unprotectedNamespaces()). The elements in the clear are also visible for recipients of other encryptions of the same stanza, e.g. OMEMO 2. Sensitive elements in other namespaces are dropped. Handlers must not have side effects, the message may be not sent after all.

client->hooks(this).add<QXmpp::Messages::PrepareBodyOnly>([](QXmpp::Messages::BodyOnlyMessage &message) {
    message.allowLowRiskElements();
});

The message is not sent to those recipients if a handler calls BodyOnlyMessage::setUnsupported(), if it is a correction whose marker is not sent in the clear (it would appear as a new message), or if it has neither a body nor elements in the clear.