comparison sat_pubsub/backend.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 ff8aff4c9b79
children 20b82fb8de02
comparison
equal deleted inserted replaced
345:83122f15b993 346:3bbab2173ebc
660 d.addCallback(lambda _: None) 660 d.addCallback(lambda _: None)
661 d.addErrback(self.unwrapFirstError) 661 d.addErrback(self.unwrapFirstError)
662 return d 662 return d
663 663
664 664
665 def getItemsIds(self, nodeIdentifier, authorized_groups, unrestricted, maxItems=None, ext_data=None, pep=False, recipient=None):
666 d = self.storage.getNode(nodeIdentifier, pep, recipient)
667 d.addCallback(lambda node: node.getItemsIds(authorized_groups,
668 unrestricted,
669 maxItems,
670 ext_data))
671 return d
672
673
665 def getItems(self, nodeIdentifier, requestor, recipient, maxItems=None, 674 def getItems(self, nodeIdentifier, requestor, recipient, maxItems=None,
666 itemIdentifiers=None, ext_data=None): 675 itemIdentifiers=None, ext_data=None):
667 d = self.getItemsData(nodeIdentifier, requestor, recipient, maxItems, itemIdentifiers, ext_data) 676 d = self.getItemsData(nodeIdentifier, requestor, recipient, maxItems, itemIdentifiers, ext_data)
668 d.addCallback(lambda items_data: [item_data.item for item_data in items_data]) 677 d.addCallback(lambda items_data: [item_data.item for item_data in items_data])
669 return d 678 return d
1274 d.addCallback(saveMetaData) 1283 d.addCallback(saveMetaData)
1275 d.addErrback(trapNotFound) 1284 d.addErrback(trapNotFound)
1276 d.addErrback(self._mapErrors) 1285 d.addErrback(self._mapErrors)
1277 return d 1286 return d
1278 1287
1279 1288 def getNodes(self, requestor, service, nodeIdentifier):
1280 def getNodes(self, requestor, service, nodeIdentifier, pep=None): 1289 try:
1281 return defer.succeed([]) # FIXME: disabled for now, need to manage PEP 1290 pep = service.pep
1291 except AttributeError:
1292 pep = False
1293
1282 if service.resource: 1294 if service.resource:
1283 return defer.succeed([]) 1295 return defer.succeed([])
1284 d = self.backend.getNodes(pep) 1296
1297 if nodeIdentifier:
1298 d = self.backend.getItemsIds(nodeIdentifier,
1299 [],
1300 requestor.userhostJID() == service,
1301 None,
1302 None,
1303 pep,
1304 service)
1305
1306 else:
1307 d = self.backend.getNodes(pep)
1285 return d.addErrback(self._mapErrors) 1308 return d.addErrback(self._mapErrors)
1286 1309
1287 1310
1288 def getConfigurationOptions(self): 1311 def getConfigurationOptions(self):
1289 return self.backend.nodeOptions 1312 return self.backend.nodeOptions