@@ -749,8 +749,7 @@ class Message::Private : public QSharedData {
749
749
QString encryptionProtocol; // XEP-0380
750
750
Message::StanzaId stanzaId; // XEP-0359
751
751
QList<Reference> references; // XEP-0385 and XEP-0372
752
-
753
- std::optional<QStringList> reactions; // XEP-0444
752
+ Message::Reactions reactions; // XEP-0444
754
753
};
755
754
756
755
#define MessageD () (d ? d : (d = new Private))
@@ -1098,9 +1097,9 @@ void Message::addReference(const Reference &r) { MessageD()->references.append(r
1098
1097
1099
1098
void Message::setReferences (const QList<Reference> &r) { MessageD ()->references = r; }
1100
1099
1101
- void Message::setReactions (const QStringList &reactions) { MessageD ()->reactions = reactions; }
1100
+ void Message::setReactions (const XMPP::Message::Reactions &reactions) { MessageD ()->reactions = reactions; }
1102
1101
1103
- std::optional<QStringList> Message::reactions () const { return d ? d->reactions : QStringList {}; }
1102
+ XMPP::Message::Reactions Message::reactions () const { return d ? d->reactions : Reactions {}; }
1104
1103
1105
1104
QString Message::invite () const { return d ? d->invite : QString (); }
1106
1105
@@ -1441,9 +1440,10 @@ Stanza Message::toStanza(Stream *stream) const
1441
1440
1442
1441
// XEP-0444
1443
1442
auto reactionsNS = QStringLiteral (" urn:xmpp:reactions:0" );
1444
- if (d->reactions ) {
1443
+ if (! d->reactions . targetId . isEmpty () ) {
1445
1444
auto e = s.createElement (reactionsNS, QStringLiteral (" reactions" ));
1446
- for (const QString &reaction : *d->reactions ) {
1445
+ e.setAttribute (QLatin1String (" id" ), d->reactions .targetId );
1446
+ for (const QString &reaction : d->reactions .reactions ) {
1447
1447
e.appendChild (s.createTextElement (reactionsNS, QStringLiteral (" reaction" ), reaction));
1448
1448
}
1449
1449
s.appendChild (e);
@@ -1805,14 +1805,15 @@ bool Message::fromStanza(const Stanza &s, bool useTimeZoneOffset, int timeZoneOf
1805
1805
auto reactionStanza
1806
1806
= childElementsByTagNameNS (root, " urn:xmpp:reactions:0" , QStringLiteral (" reactions" )).item (0 ).toElement ();
1807
1807
if (!reactionStanza.isNull ()) {
1808
- auto reactionTag = QStringLiteral (" reaction" );
1809
- QStringList reactions;
1810
- auto reaction = reactionStanza.firstChildElement (reactionTag);
1811
- while (!reaction.isNull ()) {
1812
- reactions.append (reaction.text ().trimmed ());
1813
- reaction = reaction.nextSiblingElement (reactionTag);
1808
+ d->reactions .targetId = reactionStanza.attribute (QLatin1String (" id" ));
1809
+ if (!d->reactions .targetId .isEmpty ()) {
1810
+ auto reactionTag = QStringLiteral (" reaction" );
1811
+ auto reaction = reactionStanza.firstChildElement (reactionTag);
1812
+ while (!reaction.isNull ()) {
1813
+ d->reactions .reactions .append (reaction.text ().trimmed ());
1814
+ reaction = reaction.nextSiblingElement (reactionTag);
1815
+ }
1814
1816
}
1815
- d->reactions = reactions;
1816
1817
}
1817
1818
1818
1819
return true ;
0 commit comments