plugin events: fixed blog/invitees uri handling

This commit is contained in:
Goffi 2017-05-19 13:53:52 +02:00
commit f3ae390188

View file

@ -133,7 +133,7 @@ class Events(object):
for uri_type in (u'invitees', u'blog'):
try:
elt = next(event_elt.elements(NS_EVENT, 'invitees'))
elt = next(event_elt.elements(NS_EVENT, uri_type))
uri = data[uri_type + u'_uri'] = elt['uri']
uri_data = uri_parse.parseXMPPUri(uri)
if uri_data[u'type'] != u'pubsub':
@ -203,17 +203,22 @@ class Events(object):
# we first create the invitees and blog nodes (if not specified in data)
for uri_type in (u'invitees', u'blog'):
key = uri_type + u'_uri'
for to_delete in (u'service', u'node'):
k = uri_type + u'_' + to_delete
if k in data:
del data[k]
if key not in data:
# FIXME: affiliate invitees
uri_node = yield self._p.createNode(client, service)
yield self._p.setConfiguration(client, service, uri_node, {self._p.OPT_ACCESS_MODEL: self._p.ACCESS_WHITELIST})
uri_service = service
else:
# we suppose that *_service and *_node are present
# FIXME: handle cases when they are not
uri_service = data.pop(uri_type + u'_service')
uri_node = data.pop(uri_type + u'_node')
del data[key]
uri = data.pop(key)
uri_data = uri_parse.parseXMPPUri(uri)
if uri_data[u'type'] != u'pubsub':
raise ValueError(_(u'The given URI is not valid: {uri}').format(uri=uri))
uri_service = jid.JID(uri_data[u'path'])
uri_node = uri_data[u'node']
elt = event_elt.addElement((NS_EVENT, uri_type))
elt['uri'] = uri_parse.buildXMPPUri('pubsub', path=uri_service.full(), node=uri_node)