diff --git a/sleekxmpp/plugins/xep_0060/pubsub.py b/sleekxmpp/plugins/xep_0060/pubsub.py index 990e824..a5db137 100644 --- a/sleekxmpp/plugins/xep_0060/pubsub.py +++ b/sleekxmpp/plugins/xep_0060/pubsub.py @@ -177,6 +177,12 @@ class xep_0060(base_plugin): iq['pubsub']['subscriptions']['node'] = node return iq.send(block=block, callback=callback, timeout=timeout) + def get_affiliations(self, jid, node=None, ifrom=None, block=True, + callback=None, timeout=None): + iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get') + iq['pubsub']['affiliations']['node'] = node + return iq.send(block=block, callback=callback, timeout=timeout) + def get_subscription_options(self, jid, node, user_jid, ifrom=None, block=True, callback=None, timeout=None): iq = self.xmpp.Iq(sto=jid, sfrom=ifrom, stype='get') diff --git a/sleekxmpp/plugins/xep_0060/stanza/pubsub.py b/sleekxmpp/plugins/xep_0060/stanza/pubsub.py index 0cbb738..6aaafbc 100644 --- a/sleekxmpp/plugins/xep_0060/stanza/pubsub.py +++ b/sleekxmpp/plugins/xep_0060/stanza/pubsub.py @@ -37,7 +37,7 @@ class Affiliations(ElementBase): namespace = 'http://jabber.org/protocol/pubsub' name = 'affiliations' plugin_attrib = 'affiliations' - interfaces = set(tuple()) + interfaces = set(('node',)) plugin_attrib_map = {} plugin_tag_map = {} subitem = (Affiliation,) diff --git a/tests/test_stream_xep_0060.py b/tests/test_stream_xep_0060.py index 1ace0f9..b90359f 100644 --- a/tests/test_stream_xep_0060.py +++ b/tests/test_stream_xep_0060.py @@ -666,5 +666,32 @@ class TestStreamPubsub(SleekTest): """) + def testGetAffiliations(self): + """Test retrieving a users's affiliations.""" + self.xmpp['xep_0060'].get_affiliations( + 'pubsub.example.com', + block=False) + self.send(""" + + + + + + """) + + def testGetAffiliatinssForNode(self): + """Test retrieving a users's affiliations for a given node.""" + self.xmpp['xep_0060'].get_affiliations( + 'pubsub.example.com', + node='somenode', + block=False) + self.send(""" + + + + + + """) + suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamPubsub)