aboutsummaryrefslogtreecommitdiff
path: root/src/base/QXmppMessage.cpp
diff options
context:
space:
mode:
authorMelvin Keskin <melvo@olomono.de>2022-10-16 19:59:49 +0200
committerGitHub <noreply@github.com>2022-10-16 19:59:49 +0200
commit66e5f060abe831fa08a758b9de44b29bfec8b3ba (patch)
tree0fab0a2b20d6563c3522172129f0c5520c6028b7 /src/base/QXmppMessage.cpp
parentecce762e109bc9d88f3f6b7925e8b33ffcc0f57d (diff)
Implement XEP-0444: Message Reactions (#492)
https://xmpp.org/extensions/xep-0444.html
Diffstat (limited to 'src/base/QXmppMessage.cpp')
-rw-r--r--src/base/QXmppMessage.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/base/QXmppMessage.cpp b/src/base/QXmppMessage.cpp
index 7998598c..c0923d22 100644
--- a/src/base/QXmppMessage.cpp
+++ b/src/base/QXmppMessage.cpp
@@ -11,6 +11,7 @@
#include "QXmppConstants_p.h"
#include "QXmppFileShare.h"
#include "QXmppGlobal_p.h"
+#include "QXmppMessageReaction.h"
#include "QXmppMixInvitation.h"
#ifdef BUILD_OMEMO
#include "QXmppOmemoElement_p.h"
@@ -154,6 +155,9 @@ public:
// XEP-0434: Trust Messages (TM)
std::optional<QXmppTrustMessageElement> trustMessageElement;
+ // XEP-0444: Message Reactions
+ std::optional<QXmppMessageReaction> reaction;
+
// XEP-0448: Encryption for stateless file sharing
QVector<QXmppFileShare> sharedFiles;
};
@@ -1239,6 +1243,32 @@ void QXmppMessage::setTrustMessageElement(const std::optional<QXmppTrustMessageE
}
///
+/// Returns a reaction to a message as defined by \xep{0444, Message Reactions}.
+///
+/// \since QXmpp 1.5
+///
+std::optional<QXmppMessageReaction> QXmppMessage::reaction() const
+{
+ return d->reaction;
+}
+
+///
+/// Sets a reaction to a message as defined by \xep{0444, Message Reactions}.
+///
+/// The corresponding hint must be set manually:
+/// \code
+/// QXmppMessage message;
+/// message.addHint(QXmppMessage::Store);
+/// \endcode
+///
+/// \since QXmpp 1.5
+///
+void QXmppMessage::setReaction(const std::optional<QXmppMessageReaction> &reaction)
+{
+ d->reaction = reaction;
+}
+
+///
/// Returns the via \xep{0447, Stateless file sharing} shared files attached to this message.
///
/// \since QXmpp 1.5
@@ -1544,6 +1574,13 @@ bool QXmppMessage::parseExtension(const QDomElement &element, QXmpp::SceMode sce
d->trustMessageElement = trustMessageElement;
return true;
}
+ // XEP-0444: Message Reactions
+ if (QXmppMessageReaction::isMessageReaction(element)) {
+ QXmppMessageReaction reaction;
+ reaction.parse(element);
+ d->reaction = std::move(reaction);
+ return true;
+ }
// XEP-0448: Stateless file sharing
if (checkElement(element, QStringLiteral("file-sharing"), ns_sfs)) {
QXmppFileShare share;
@@ -1800,6 +1837,11 @@ void QXmppMessage::serializeExtensions(QXmlStreamWriter *writer, QXmpp::SceMode
d->trustMessageElement->toXml(writer);
}
+ // XEP-0444: Message Reactions
+ if (d->reaction) {
+ d->reaction->toXml(writer);
+ }
+
// XEP-0448: Stateless file sharing
for (const auto &fileShare : d->sharedFiles) {
fileShare.toXml(writer);