comparison sat_pubsub/delegation.py @ 346:3bbab2173ebc

implemented disco items: - new getItemsIds method to get only ids of items, without payload or extra data - added delegation (PEP) data for disco items requests. It's a really dirty hack, but there is not clean way to do it beside rewriting the whole thing - authorized node items are returned on disco items when node is specified - if no node is specified, the nodes list is returned
author Goffi <goffi@goffi.org>
date Thu, 24 Aug 2017 01:17:28 +0200
parents 0a93d71f9503
children
comparison
equal deleted inserted replaced
345:83122f15b993 346:3bbab2173ebc
264 d.addCallback(gotInfos) 264 d.addCallback(gotInfos)
265 return d 265 return d
266 266
267 def getDiscoItems(self, requestor, target, nodeIdentifier=''): 267 def getDiscoItems(self, requestor, target, nodeIdentifier=''):
268 return [] 268 return []
269
270
271 # we monkeypatch DiscoHandler to add delegation informations
272 def _onDiscoItems(self, iq):
273 request = disco._DiscoRequest.fromElement(iq)
274 # it's really ugly to attach pep data to recipient
275 # but we don't have many options
276 request.recipient.pep = iq.delegated
277
278 def toResponse(items):
279 response = disco.DiscoItems()
280 response.nodeIdentifier = request.nodeIdentifier
281
282 for item in items:
283 response.append(item)
284
285 return response.toElement()
286
287 d = self.items(request.sender, request.recipient,
288 request.nodeIdentifier)
289 d.addCallback(toResponse)
290 return d
291
292
293 disco.DiscoHandler._onDiscoItems = _onDiscoItems