comparison src/plugins/plugin_xep_0277.py @ 1649:b58c8b4715c6

plugin XEP-0277: fixed entries in atom feed
author Goffi <goffi@goffi.org>
date Mon, 23 Nov 2015 15:51:19 +0100
parents 2b8a975ff712
children 069abd15354f
comparison
equal deleted inserted replaced
1648:2b8a975ff712 1649:b58c8b4715c6
855 855
856 @return: a deferred couple with the list of items and metadatas. 856 @return: a deferred couple with the list of items and metadatas.
857 """ 857 """
858 if node is None: 858 if node is None:
859 node = NS_MICROBLOG 859 node = NS_MICROBLOG
860 items, metadata = 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)
861 860
862 feed_elt = domish.Element((NS_ATOM, 'feed')) 861 feed_elt = domish.Element((NS_ATOM, 'feed'))
863 title = D_(u"{user}'s blogposts").format(user=service_jid.user) 862 title = D_(u"{user}'s blogposts").format(user=service_jid.user)
864 feed_elt.addElement('title', content=title) 863 feed_elt.addElement('title', content=title)
865 link_feed_elt = feed_elt.addElement('link') 864 link_feed_elt = feed_elt.addElement('link')
872 host=urllib.quote(service_jid.host,''), 871 host=urllib.quote(service_jid.host,''),
873 user=urllib.quote(service_jid.user,'')) 872 user=urllib.quote(service_jid.user,''))
874 feed_elt.addElement('id', content=node) 873 feed_elt.addElement('id', content=node)
875 feed_elt.addElement('updated', rfc3339.timestamp_from_tf(rfc3339.tf_utc())) 874 feed_elt.addElement('updated', rfc3339.timestamp_from_tf(rfc3339.tf_utc()))
876 875
876 # FIXME: no cleaning is done here
877 # FIXME: no check is done neither, we have to be sure that we get microblogs
878 items, metadata = 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)
879
880 for item in items:
881 entry_elt = item.elements(NS_ATOM, 'entry').next()
882 feed_elt.addChild(entry_elt)
883
877 defer.returnValue(u'<?xml version="1.0" encoding="utf-8"?>'+feed_elt.toXml()) 884 defer.returnValue(u'<?xml version="1.0" encoding="utf-8"?>'+feed_elt.toXml())