From 386a5c71647ad95a7e8886dfca1bcf2bf07d5293 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Fri, 13 May 2022 21:40:44 +0200 Subject: Client: injectIq: Send error IQ on unhandled IQs --- src/client/QXmppClient.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/client/QXmppClient.cpp') diff --git a/src/client/QXmppClient.cpp b/src/client/QXmppClient.cpp index cfe798fd..a90fafed 100644 --- a/src/client/QXmppClient.cpp +++ b/src/client/QXmppClient.cpp @@ -786,7 +786,25 @@ QXmppVersionManager &QXmppClient::versionManager() void QXmppClient::injectIq(const QDomElement &element, const std::optional &e2eeMetadata) { - StanzaPipeline::process(d->extensions, element, e2eeMetadata); + if (element.tagName() != "iq") { + return; + } + if (!StanzaPipeline::process(d->extensions, element, e2eeMetadata)) { + const auto iqType = element.attribute("type"); + if (iqType == "get" || iqType == "set") { + // send error IQ + using Err = QXmppStanza::Error; + + QXmppIq iq(QXmppIq::Error); + iq.setTo(element.attribute("from")); + const auto errMessage = e2eeMetadata.has_value() + ? QStringLiteral("Feature not implemented or not supported with end-to-end encryption.") + : QStringLiteral("Feature not implemented."); + iq.setError(Err(Err::Cancel, Err::FeatureNotImplemented, errMessage)); + reply(std::move(iq), e2eeMetadata); + } + // don't do anything for "result" and "error" IQs + } } /// -- cgit v1.2.3