Skip to content

Commit e50f3d3

Browse files
committed
Added XEP-0424: message retraction support
1 parent c94e7df commit e50f3d3

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/xmpp/xmpp-im/types.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,7 @@ class Message::Private : public QSharedData {
752752
Message::StanzaId stanzaId; // XEP-0359
753753
QList<Reference> references; // XEP-0385 and XEP-0372
754754
Message::Reactions reactions; // XEP-0444
755+
QString retraction; // XEP-0424
755756
};
756757

757758
#define MessageD() (d ? d : (d = new Private))
@@ -1103,6 +1104,10 @@ void Message::setReactions(const XMPP::Message::Reactions &reactions) { MessageD
11031104

11041105
XMPP::Message::Reactions Message::reactions() const { return d ? d->reactions : Reactions {}; }
11051106

1107+
void Message::setRetraction(const QString &retractedMessageId) { MessageD()->retraction = retractedMessageId; }
1108+
1109+
QString Message::retraction() const { return d ? d->retraction : QString {}; }
1110+
11061111
QString Message::invite() const { return d ? d->invite : QString(); }
11071112

11081113
void Message::setInvite(const QString &s) { MessageD()->invite = s; }
@@ -1452,6 +1457,14 @@ Stanza Message::toStanza(Stream *stream) const
14521457
s.appendChild(s.createElement(QStringLiteral("urn:xmpp:hints"), QStringLiteral("store")));
14531458
}
14541459

1460+
// XEP-0424
1461+
if (!d->retraction.isEmpty()) {
1462+
auto e = s.createElement("urn:xmpp:message-retract:1", QStringLiteral("retract"));
1463+
e.setAttribute(QLatin1String("id"), d->retraction);
1464+
s.appendChild(e);
1465+
s.appendChild(s.createElement(QStringLiteral("urn:xmpp:hints"), QStringLiteral("store")));
1466+
}
1467+
14551468
return s;
14561469
}
14571470

@@ -1820,6 +1833,11 @@ bool Message::fromStanza(const Stanza &s, bool useTimeZoneOffset, int timeZoneOf
18201833
}
18211834
}
18221835

1836+
// XEP-0424 message retraction
1837+
d->retraction = childElementsByTagNameNS(root, "urn:xmpp:message-retract:1", QStringLiteral("retract"))
1838+
.item(0)
1839+
.toElement()
1840+
.attribute(QLatin1String("id"));
18231841
return true;
18241842
}
18251843

src/xmpp/xmpp-im/xmpp_message.h

+3
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ class Message {
230230
void setReactions(const Reactions &reactions);
231231
Reactions reactions() const;
232232

233+
void setRetraction(const QString &retractedMessageId);
234+
QString retraction() const;
235+
233236
// Obsolete invitation
234237
QString invite() const;
235238
void setInvite(const QString &s);

0 commit comments

Comments
 (0)