plugin XEP-0060, groupblog: added nodeIdentifiers attribute to getItems in order to retrieve items by ids
This commit is contained in:
parent
765eecb37c
commit
2b2fa9fd4a
1 changed files with 79 additions and 6 deletions
|
|
@ -99,9 +99,9 @@ class XEP_0060(object):
|
|||
profile, client = self.__getClientNProfile(profile_key, 'publish item')
|
||||
return client.publish(service, nodeIdentifier, items, client.parent.jid)
|
||||
|
||||
def getItems(self, service, node, max_items=None, sub_id=None, profile_key='@DEFAULT@'):
|
||||
def getItems(self, service, node, max_items=None, item_ids=None, sub_id=None, profile_key='@DEFAULT@'):
|
||||
profile, client = self.__getClientNProfile(profile_key, 'get items')
|
||||
return client.items(service, node, max_items, sub_id, client.parent.jid)
|
||||
return client.items(service, node, max_items, item_ids, sub_id, client.parent.jid)
|
||||
|
||||
def getOptions(self, service, nodeIdentifier, subscriber, subscriptionIdentifier=None, profile_key='@DEFAULT@'):
|
||||
profile, client = self.__getClientNProfile(profile_key, 'get options')
|
||||
|
|
@ -139,7 +139,54 @@ class SatPubSubClient(pubsub.PubSubClient):
|
|||
def connectionInitialized(self):
|
||||
pubsub.PubSubClient.connectionInitialized(self)
|
||||
|
||||
# XXX: this should be done in wokkel
|
||||
# FIXME: we have to temporary override this method here just
|
||||
# to set the attributes itemIdentifiers which is not used
|
||||
# in pubsub.PubSubClient.items
|
||||
def items(self, service, nodeIdentifier, maxItems=None, itemIdentifiers=None,
|
||||
subscriptionIdentifier=None, sender=None):
|
||||
"""
|
||||
Retrieve previously published items from a publish subscribe node.
|
||||
|
||||
@param service: The publish subscribe service that keeps the node.
|
||||
@type service: L{JID<twisted.words.protocols.jabber.jid.JID>}
|
||||
|
||||
@param nodeIdentifier: The identifier of the node.
|
||||
@type nodeIdentifier: C{unicode}
|
||||
|
||||
@param maxItems: Optional limit on the number of retrieved items.
|
||||
@type maxItems: C{int}
|
||||
|
||||
@param itemIdentifiers: Identifiers of the items to be retracted.
|
||||
@type itemIdentifiers: C{set}
|
||||
|
||||
@param subscriptionIdentifier: Optional subscription identifier. In
|
||||
case the node has been subscribed to multiple times, this narrows
|
||||
the results to the specific subscription.
|
||||
@type subscriptionIdentifier: C{unicode}
|
||||
"""
|
||||
NS_PUBSUB = 'http://jabber.org/protocol/pubsub'
|
||||
|
||||
request = PubSubRequest('items')
|
||||
request.recipient = service
|
||||
request.nodeIdentifier = nodeIdentifier
|
||||
if maxItems:
|
||||
request.maxItems = str(int(maxItems))
|
||||
request.subscriptionIdentifier = subscriptionIdentifier
|
||||
request.sender = sender
|
||||
request.itemIdentifiers = itemIdentifiers # XXX: this line has been added
|
||||
|
||||
def cb(iq):
|
||||
items = []
|
||||
for element in iq.pubsub.items.elements():
|
||||
if element.uri == NS_PUBSUB and element.name == 'item':
|
||||
items.append(element)
|
||||
return items
|
||||
|
||||
d = request.send(self.xmlstream)
|
||||
d.addCallback(cb)
|
||||
return d
|
||||
|
||||
# FIXME: this should be done in wokkel
|
||||
def retractItems(self, service, nodeIdentifier, itemIdentifiers, sender=None):
|
||||
"""
|
||||
Retract items from a publish subscribe node.
|
||||
|
|
|
|||
Loading…
Reference in a new issue