# HG changeset patch # User Goffi # Date 1495194832 -7200 # Node ID e8641b7718dcd121d4312857e5587eebbc27440b # Parent e09048cb7595247196a5d4a5bde5cd56896971d7 plugin events: fixed blog/invitees uri handling diff -r e09048cb7595 -r e8641b7718dc src/plugins/plugin_exp_events.py --- a/src/plugins/plugin_exp_events.py Fri May 19 12:54:31 2017 +0200 +++ b/src/plugins/plugin_exp_events.py Fri May 19 13:53:52 2017 +0200 @@ -133,7 +133,7 @@ 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 @@ # 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)