plugin XEP-0060, XEP-0277: added getNodeURI method
This commit is contained in:
parent
43ecaa5af9
commit
0815ee1576
1 changed files with 19 additions and 4 deletions
|
|
@ -31,6 +31,7 @@ from wokkel import disco
|
|||
from wokkel import data_form
|
||||
from zope.interface import implements
|
||||
from collections import namedtuple
|
||||
import urllib
|
||||
import datetime
|
||||
from dateutil import tz
|
||||
# XXX: tmp.wokkel.pubsub is actually use instead of wokkel version
|
||||
|
|
@ -400,6 +401,23 @@ class XEP_0060(object):
|
|||
client = self.host.getClient(profile_key)
|
||||
return client.pubsub_client.subscriptions(service, nodeIdentifier)
|
||||
|
||||
## misc tools ##
|
||||
|
||||
def getNodeURI(self, service, node, item=None):
|
||||
"""Return XMPP URI of a PubSub node
|
||||
|
||||
@param service(jid.JID, None): PubSub service,
|
||||
@param node(unicode): node
|
||||
@return (unicode): URI of the node
|
||||
"""
|
||||
query_data = [('node', node.encode('utf-8'))]
|
||||
if item is not None:
|
||||
query_data.append(('item', item.encode('utf-8')))
|
||||
return "xmpp:{service}?{query}".format(
|
||||
service=service.userhost(),
|
||||
query=urllib.urlencode(query_data)
|
||||
).decode('utf-8')
|
||||
|
||||
## methods to manage several stanzas/jids at once ##
|
||||
|
||||
# generic #
|
||||
|
|
|
|||
Loading…
Reference in a new issue