summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2016-10-04 19:32:45 +0200
committerlouiz’ <louiz@louiz.org>2016-10-04 19:32:45 +0200
commit1d197ff26ce5a88ba851969edb3ea915759c3477 (patch)
tree3706ab8ccc247525675ddde1456b3e73bba99abc
parent28f1dd76548fc9a7de3920d938903f68cdfffe0d (diff)
downloadbiboumi-1d197ff26ce5a88ba851969edb3ea915759c3477.tar.gz
biboumi-1d197ff26ce5a88ba851969edb3ea915759c3477.tar.bz2
biboumi-1d197ff26ce5a88ba851969edb3ea915759c3477.tar.xz
biboumi-1d197ff26ce5a88ba851969edb3ea915759c3477.zip
Respond to muc#traffic requests
fix #3069
-rw-r--r--louloulibs/xmpp/xmpp_component.hpp1
-rw-r--r--src/xmpp/biboumi_component.cpp26
-rw-r--r--src/xmpp/biboumi_component.hpp5
-rw-r--r--tests/end_to_end/__main__.py35
4 files changed, 66 insertions, 1 deletions
diff --git a/louloulibs/xmpp/xmpp_component.hpp b/louloulibs/xmpp/xmpp_component.hpp
index 4b6f37d..1cb1845 100644
--- a/louloulibs/xmpp/xmpp_component.hpp
+++ b/louloulibs/xmpp/xmpp_component.hpp
@@ -32,6 +32,7 @@
#define CLIENT_NS "jabber:client"
#define DATAFORM_NS "jabber:x:data"
#define RSM_NS "http://jabber.org/protocol/rsm"
+#define MUC_TRAFFIC_NS "http://jabber.org/protocol/muc#traffic"
/**
* An XMPP component, communicating with an XMPP server using the protocole
diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp
index 1e66b62..b9a8779 100644
--- a/src/xmpp/biboumi_component.cpp
+++ b/src/xmpp/biboumi_component.cpp
@@ -408,6 +408,13 @@ void BiboumiComponent::handle_iq(const Stanza& stanza)
stanza_error.disable();
}
}
+ else if (iid.type == Iid::Type::Channel)
+ {
+ if (node == MUC_TRAFFIC_NS)
+ {
+ this->send_irc_channel_muc_traffic_info(id, from, to_str);
+ }
+ }
}
else if ((query = stanza.get_child("query", VERSION_NS)))
{
@@ -724,6 +731,25 @@ void BiboumiComponent::send_irc_server_disco_info(const std::string& id, const s
this->send_stanza(iq);
}
+void BiboumiComponent::send_irc_channel_muc_traffic_info(const std::string id, const std::string& jid_from, const std::string& jid_to)
+{
+ Stanza iq("iq");
+ iq["type"] = "result";
+ iq["id"] = id;
+ iq["from"] = jid_from;
+ iq["to"] = jid_to;
+
+ XmlNode query("query");
+ query["xmlns"] = DISCO_INFO_NS;
+ query["node"] = MUC_TRAFFIC_NS;
+ // We drop all “special” traffic (like xhtml-im, chatstates, etc), so
+ // don’t include any <feature/>
+ iq.add_child(std::move(iq));
+
+ this->send_stanza(iq);
+
+}
+
void BiboumiComponent::send_iq_version_request(const std::string& from,
const std::string& jid_to)
{
diff --git a/src/xmpp/biboumi_component.hpp b/src/xmpp/biboumi_component.hpp
index 77104ed..d5b87e9 100644
--- a/src/xmpp/biboumi_component.hpp
+++ b/src/xmpp/biboumi_component.hpp
@@ -66,6 +66,11 @@ public:
*/
void send_irc_server_disco_info(const std::string& id, const std::string& jid_to, const std::string& jid_from);
/**
+ * Sends the allowed namespaces in MUC message, according to
+ * http://xmpp.org/extensions/xep-0045.html#impl-service-traffic
+ */
+ void send_irc_channel_muc_traffic_info(const std::string id, const std::string& jid_from, const std::string& jid_to);
+ /**
* Send an iq version request
*/
void send_iq_version_request(const std::string& from,
diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py
index 25cf29c..a4fc239 100644
--- a/tests/end_to_end/__main__.py
+++ b/tests/end_to_end/__main__.py
@@ -110,6 +110,8 @@ def match(stanza, xpath):
tree = lxml.etree.parse(io.StringIO(str(stanza)))
matched = tree.xpath(xpath, namespaces={'re': 'http://exslt.org/regular-expressions',
'muc_user': 'http://jabber.org/protocol/muc#user',
+ 'disco_info': 'http://jabber.org/protocol/disco#info',
+ 'muc_traffic': 'http://jabber.org/protocol/muc#traffic',
'disco_items': 'http://jabber.org/protocol/disco#items',
'commands': 'http://jabber.org/protocol/commands',
'dataform': 'jabber:x:data',
@@ -1463,7 +1465,38 @@ if __name__ == '__main__':
"/iq/disco_items:query/rsm:set/rsm:last[text()='#jjj%{irc_server_one}']",
"/iq/disco_items:query/rsm:set/rsm:count[text()='10']"
)),
- ])
+
+ partial(log_message, "Leaving the 10 channels"),
+ partial(send_stanza, "<presence from='{jid_one}/{resource_one}' to='#aaa%{irc_server_one}/{nick_one}' type='unavailable' />"),
+ partial(send_stanza, "<presence from='{jid_one}/{resource_one}' to='#bbb%{irc_server_one}/{nick_one}' type='unavailable' />"),
+ partial(send_stanza, "<presence from='{jid_one}/{resource_one}' to='#ccc%{irc_server_one}/{nick_one}' type='unavailable' />"),
+ partial(send_stanza, "<presence from='{jid_one}/{resource_one}' to='#ddd%{irc_server_one}/{nick_one}' type='unavailable' />"),
+ partial(send_stanza, "<presence from='{jid_one}/{resource_one}' to='#eee%{irc_server_one}/{nick_one}' type='unavailable' />"),
+ partial(send_stanza, "<presence from='{jid_one}/{resource_one}' to='#fff%{irc_server_one}/{nick_one}' type='unavailable' />"),
+ partial(send_stanza, "<presence from='{jid_one}/{resource_one}' to='#ggg%{irc_server_one}/{nick_one}' type='unavailable' />"),
+ partial(send_stanza, "<presence from='{jid_one}/{resource_one}' to='#hhh%{irc_server_one}/{nick_one}' type='unavailable' />"),
+ partial(send_stanza, "<presence from='{jid_one}/{resource_one}' to='#iii%{irc_server_one}/{nick_one}' type='unavailable' />"),
+ partial(send_stanza, "<presence from='{jid_one}/{resource_one}' to='#jjj%{irc_server_one}/{nick_one}' type='unavailable' />"),
+ partial(expect_stanza, "/presence[@type='unavailable']"),
+ partial(expect_stanza, "/presence[@type='unavailable']"),
+ partial(expect_stanza, "/presence[@type='unavailable']"),
+ partial(expect_stanza, "/presence[@type='unavailable']"),
+ partial(expect_stanza, "/presence[@type='unavailable']"),
+ partial(expect_stanza, "/presence[@type='unavailable']"),
+ partial(expect_stanza, "/presence[@type='unavailable']"),
+ partial(expect_stanza, "/presence[@type='unavailable']"),
+ partial(expect_stanza, "/presence[@type='unavailable']"),
+ partial(expect_stanza, "/presence[@type='unavailable']")
+ ]),
+ Scenario("muc_traffic_info",
+ [
+ handshake_sequence(),
+
+ partial(send_stanza,
+ "<iq from='{jid_one}/{resource_one}' to='#foo%{irc_server_one}' />"),
+ partial(expect_stanza, "/iq[@type='result']/disco_info:query[@node='{muc_traffic}']"),
+ ]),
+
)
failures = 0