comparison src/plugins/plugin_xep_0277.py @ 1865:fc6eeacf31bc

plugin XEP-0277: service can be None in mbGet, resulting in a request on default pubsub service of profile (i.e. profile's PEP)
author Goffi <goffi@goffi.org>
date Tue, 01 Mar 2016 01:47:32 +0100
parents 3c0bb714a80b
children 085f29c20f7e
comparison
equal deleted inserted replaced
1864:96ba685162f6 1865:fc6eeacf31bc
575 """Call self._p._retractItem, but use default node if node is empty""" 575 """Call self._p._retractItem, but use default node if node is empty"""
576 return self._p._retractItem(service_jid_s, nodeIdentifier or NS_MICROBLOG, itemIdentifier, True, profile_key) 576 return self._p._retractItem(service_jid_s, nodeIdentifier or NS_MICROBLOG, itemIdentifier, True, profile_key)
577 577
578 ## get ## 578 ## get ##
579 579
580 def _mbGet(self, service_jid_s, node="", max_items=10, item_ids=None, extra_dict=None, profile_key=C.PROF_KEY_NONE): 580 def _mbGet(self, service='', node='', max_items=10, item_ids=None, extra_dict=None, profile_key=C.PROF_KEY_NONE):
581 """ 581 """
582 @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit 582 @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit
583 @param item_ids (list[unicode]): list of item IDs 583 @param item_ids (list[unicode]): list of item IDs
584 """ 584 """
585 service = jid.JID(service) if service else None
585 max_items = None if max_items == C.NO_LIMIT else max_items 586 max_items = None if max_items == C.NO_LIMIT else max_items
586 extra = self._p.parseExtra(extra_dict) 587 extra = self._p.parseExtra(extra_dict)
587 return self.mbGet(jid.JID(service_jid_s), node or None, max_items or None, item_ids, extra.rsm_request, extra.extra, profile_key) 588 return self.mbGet(service, node or None, max_items or None, item_ids, extra.rsm_request, extra.extra, profile_key)
589
588 590
589 @defer.inlineCallbacks 591 @defer.inlineCallbacks
590 def mbGet(self, service_jid, node=None, max_items=None, item_ids=None, rsm_request=None, extra=None, profile_key=C.PROF_KEY_NONE): 592 def mbGet(self, service=None, node=None, max_items=None, item_ids=None, rsm_request=None, extra=None, profile_key=C.PROF_KEY_NONE):
591 """Get some microblogs 593 """Get some microblogs
592 594
593 @param service_jid(jid.JID): jid of the publisher 595 @param service(jid.JID, None): jid of the publisher
596 None to get profile's PEP
594 @param node(unicode, None): node to get (or microblog node if None) 597 @param node(unicode, None): node to get (or microblog node if None)
595 @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit 598 @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit
596 @param item_ids (list[unicode]): list of item IDs 599 @param item_ids (list[unicode]): list of item IDs
597 @param rsm_request (rsm.RSMRequest): RSM request data 600 @param rsm_request (rsm.RSMRequest): RSM request data
598 @param extra (dict): extra data 601 @param extra (dict): extra data
600 603
601 @return: a deferred couple with the list of items and metadatas. 604 @return: a deferred couple with the list of items and metadatas.
602 """ 605 """
603 if node is None: 606 if node is None:
604 node = NS_MICROBLOG 607 node = NS_MICROBLOG
605 items_data = yield self._p.getItems(service_jid, node, max_items=max_items, item_ids=item_ids, rsm_request=rsm_request, extra=extra, profile_key=profile_key) 608 items_data = yield self._p.getItems(service, node, max_items=max_items, item_ids=item_ids, rsm_request=rsm_request, extra=extra, profile_key=profile_key)
606 serialised = yield self._p.serItemsDataD(items_data, self.item2mbdata) 609 serialised = yield self._p.serItemsDataD(items_data, self.item2mbdata)
607 defer.returnValue(serialised) 610 defer.returnValue(serialised)
608 611
609 def parseCommentUrl(self, node_url): 612 def parseCommentUrl(self, node_url):
610 """Parse a XMPP URI 613 """Parse a XMPP URI