Mercurial > libervia-backend
changeset 1902:085f29c20f7e
plugin XEP-0277: removed mbGetAtom which has not reason to be in the backend, as it is highly dependant of (web) frontend elements. The code will be moved to Libervia:
/!\ this break Libervia static blog temporarily, the time to commit the changes
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 09 Mar 2016 14:33:54 +0100 |
parents | faa8427dd032 |
children | 29564cec913f |
files | src/plugins/plugin_xep_0277.py |
diffstat | 1 files changed, 1 insertions(+), 64 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0277.py Wed Mar 09 12:54:26 2016 +0100 +++ b/src/plugins/plugin_xep_0277.py Wed Mar 09 14:33:54 2016 +0100 @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from sat.core.i18n import _, D_ +from sat.core.i18n import _ from sat.core.constants import Const as C from sat.core.log import getLogger log = getLogger(__name__) @@ -39,7 +39,6 @@ import uuid import time import urlparse -import urllib NS_MICROBLOG = 'urn:xmpp:microblog:0' NS_ATOM = 'http://www.w3.org/2005/Atom' @@ -102,8 +101,6 @@ method=self._mbGetFromManyWithCommentsRTResult, async=True) host.bridge.addMethod("mbGetFromManyWithComments", ".plugin", in_sign='sasiia{ss}a{ss}s', out_sign='s', method=self._mbGetFromManyWithComments) - host.bridge.addMethod("mbGetAtom", ".plugin", in_sign='ssiasa{ss}s', out_sign='s', - method=self._mbGetAtom, async=True) def _checkFeaturesCb(self, available): return {'available': C.BOOL_TRUE} @@ -913,63 +910,3 @@ d.addErrback(lambda failure: (unicode(failure.value), ([],{}))) return self.rt_sessions.newSession(deferreds, client.profile) - - # atom feed - - def _mbGetAtom(self, service_jid_s, node="", max_items=10, item_ids=None, extra_dict=None, profile_key=C.PROF_KEY_NONE): - """Get the atom feed of the last published microblogs - - @param service_jid(jid.JID): jid of the publisher - @param node(unicode, None): node to get (or microblog node if None) - @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit - @param item_ids (list[unicode]): list of item IDs - @param rsm_request (rsm.RSMRequest): RSM request data - @param extra (dict): extra data - @param profile_key: %(doc_profile_key)s - @return: a deferred unicode (atom XML feed) - """ - max_items = None if max_items == C.NO_LIMIT else max_items - extra = self._p.parseExtra(extra_dict) - return self.mbGetAtom(jid.JID(service_jid_s), node or None, max_items or None, item_ids, extra.rsm_request, extra.extra, profile_key) - - @defer.inlineCallbacks - def mbGetAtom(self, service_jid, node=None, max_items=None, item_ids=None, rsm_request=None, extra=None, profile_key=C.PROF_KEY_NONE): - """Get the atom feed of the last published microblogs - - @param service_jid(jid.JID): jid of the publisher - @param node(unicode, None): node to get (or microblog node if None) - @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit - @param item_ids (list[unicode]): list of item IDs - @param rsm_request (rsm.RSMRequest): RSM request data - @param extra (dict): extra data - @param profile_key: %(doc_profile_key)s - - @return: a deferred couple with the list of items and metadatas. - """ - if node is None: - node = NS_MICROBLOG - - feed_elt = domish.Element((NS_ATOM, 'feed')) - title = D_(u"{user}'s blogposts").format(user=service_jid.user) - feed_elt.addElement('title', content=title) - link_feed_elt = feed_elt.addElement('link') - link_feed_elt['href'] = 'http://{host}/blog/{user}/atom.xml'.format( - host=urllib.quote(service_jid.host.encode('utf-8'),''), - user=urllib.quote(service_jid.user.encode('utf-8'),'')) - link_feed_elt['rel'] = 'self' - link_blog_elt = feed_elt.addElement('link') - link_blog_elt['href'] = 'http://{host}/blog/{user}'.format( - host=urllib.quote(service_jid.host.encode('utf-8'),''), - user=urllib.quote(service_jid.user.encode('utf-8'),'')) - feed_elt.addElement('id', content=node) - feed_elt.addElement('updated', rfc3339.timestamp_from_tf(rfc3339.tf_utc())) - - # FIXME: no cleaning is done here - # FIXME: no check is done neither, we have to be sure that we get microblogs - 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) - - for item in items: - entry_elt = item.elements(NS_ATOM, 'entry').next() - feed_elt.addChild(entry_elt) - - defer.returnValue(u'<?xml version="1.0" encoding="utf-8"?>'+feed_elt.toXml())