comparison src/plugins/plugin_exp_events.py @ 2246:e8641b7718dc

plugin events: fixed blog/invitees uri handling
author Goffi <goffi@goffi.org>
date Fri, 19 May 2017 13:53:52 +0200
parents 5e12fc5ae52a
children b5befe7722d3
comparison
equal deleted inserted replaced
2245:e09048cb7595 2246:e8641b7718dc
131 except KeyError: 131 except KeyError:
132 log.warning(_(u'no src found for image')) 132 log.warning(_(u'no src found for image'))
133 133
134 for uri_type in (u'invitees', u'blog'): 134 for uri_type in (u'invitees', u'blog'):
135 try: 135 try:
136 elt = next(event_elt.elements(NS_EVENT, 'invitees')) 136 elt = next(event_elt.elements(NS_EVENT, uri_type))
137 uri = data[uri_type + u'_uri'] = elt['uri'] 137 uri = data[uri_type + u'_uri'] = elt['uri']
138 uri_data = uri_parse.parseXMPPUri(uri) 138 uri_data = uri_parse.parseXMPPUri(uri)
139 if uri_data[u'type'] != u'pubsub': 139 if uri_data[u'type'] != u'pubsub':
140 raise ValueError 140 raise ValueError
141 except StopIteration: 141 except StopIteration:
201 elt['src'] = data.pop(key) 201 elt['src'] = data.pop(key)
202 202
203 # we first create the invitees and blog nodes (if not specified in data) 203 # we first create the invitees and blog nodes (if not specified in data)
204 for uri_type in (u'invitees', u'blog'): 204 for uri_type in (u'invitees', u'blog'):
205 key = uri_type + u'_uri' 205 key = uri_type + u'_uri'
206 for to_delete in (u'service', u'node'):
207 k = uri_type + u'_' + to_delete
208 if k in data:
209 del data[k]
206 if key not in data: 210 if key not in data:
207 # FIXME: affiliate invitees 211 # FIXME: affiliate invitees
208 uri_node = yield self._p.createNode(client, service) 212 uri_node = yield self._p.createNode(client, service)
209 yield self._p.setConfiguration(client, service, uri_node, {self._p.OPT_ACCESS_MODEL: self._p.ACCESS_WHITELIST}) 213 yield self._p.setConfiguration(client, service, uri_node, {self._p.OPT_ACCESS_MODEL: self._p.ACCESS_WHITELIST})
210 uri_service = service 214 uri_service = service
211 else: 215 else:
212 # we suppose that *_service and *_node are present 216 uri = data.pop(key)
213 # FIXME: handle cases when they are not 217 uri_data = uri_parse.parseXMPPUri(uri)
214 uri_service = data.pop(uri_type + u'_service') 218 if uri_data[u'type'] != u'pubsub':
215 uri_node = data.pop(uri_type + u'_node') 219 raise ValueError(_(u'The given URI is not valid: {uri}').format(uri=uri))
216 del data[key] 220 uri_service = jid.JID(uri_data[u'path'])
221 uri_node = uri_data[u'node']
217 222
218 elt = event_elt.addElement((NS_EVENT, uri_type)) 223 elt = event_elt.addElement((NS_EVENT, uri_type))
219 elt['uri'] = uri_parse.buildXMPPUri('pubsub', path=uri_service.full(), node=uri_node) 224 elt['uri'] = uri_parse.buildXMPPUri('pubsub', path=uri_service.full(), node=uri_node)
220 225
221 # remaining data are put in <meta> elements 226 # remaining data are put in <meta> elements