QXmppMessageRetraction Class

The QXmppMessageRetraction class represents a message retraction as defined by XEP-0424: Message Retraction. More...

Header: #include <QXmppMessageRetraction.h>
Since: QXmpp 1.17

Public Functions

QXmppMessageRetraction()
QXmppMessageRetraction(QString retractedId)
const std::optional<QXmppMessageModeration> &moderation() const
(since QXmpp 1.18) QString reason() const
QString retractedId() const
void setModeration(const std::optional<QXmppMessageModeration> &moderation)
(since QXmpp 1.18) void setReason(const QString &reason)
void setRetractedId(const QString &id)

Detailed Description

Indicates that a previously sent message should be removed, together with all of its XEP-0308: Last Message Correction corrections. The retracted message is referenced by its id (see retractedId()).

To make messages retractable, applications need to set a globally unique 'id' on them, e.g. a UUID (see QXmppUtils::generateStanzaUuid()).

If the retraction was performed by a XEP-0045: Multi-User Chat moderator (XEP-0425: Moderated Message Retraction), moderation() carries information about the moderator.

When sending a retraction, you should add the XEP-0334: Message Processing Hints store hint (QXmppMessage::Store). A human-readable fallback body is optional; if you add one, mark it with a XEP-0428: Fallback Indication marker (see QXmppMessage::setFallbackMarkers()).

Clients must not display the body of a received retraction, even if no message with the retracted id is known. Received retractions containing a XEP-0308: Last Message Correction <replace/> element must only be processed as retractions.

Member Function Documentation

[constexpr noexcept default] QXmppMessageRetraction::QXmppMessageRetraction()

Default-constructs an instance of QXmppMessageRetraction.

[explicit] QXmppMessageRetraction::QXmppMessageRetraction(QString retractedId)

Constructs a message retraction referencing the message with the given retractedId.

const std::optional<QXmppMessageModeration> &QXmppMessageRetraction::moderation() const

Returns the moderation information, set only for XEP-0425: Moderated Message Retraction retractions.

See also setModeration().

[since QXmpp 1.18] QString QXmppMessageRetraction::reason() const

Returns the optional human-readable reason for the retraction.

The reason must only be displayed together with the retracted message, after the retraction has been processed, i.e. it refers to a known message and has been sent by its author or a moderator.

This function was introduced in QXmpp 1.18.

See also setReason().

QString QXmppMessageRetraction::retractedId() const

Returns the id of the message being retracted.

This is the 'id' attribute of the original message in 1:1 chats, or the XEP-0359: Unique and Stable Stanza IDs stanza id assigned by the room in group chats. It always refers to the original message, not to one of its corrections.

The id is empty if the retraction is embedded into another element that identifies the message differently, e.g. a XEP-0425: Moderated Message Retraction request.

See also setRetractedId().

void QXmppMessageRetraction::setModeration(const std::optional<QXmppMessageModeration> &moderation)

Sets the moderation information for a XEP-0425: Moderated Message Retraction retraction.

See also moderation().

[since QXmpp 1.18] void QXmppMessageRetraction::setReason(const QString &reason)

Sets the optional human-readable reason for the retraction.

The reason should not repeat the content of the retracted message.

This function was introduced in QXmpp 1.18.

See also reason().

void QXmppMessageRetraction::setRetractedId(const QString &id)

Sets the id of the message being retracted.

See also retractedId().