Mercurial > libervia-backend
changeset 1664:5d0ff155be1a
plugin XEP-0277: tags are handled through atom categories
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 24 Nov 2015 23:18:32 +0100 |
parents | 47224056ce5c |
children | 14fcbaa82fd4 |
files | src/plugins/plugin_misc_groupblog.py src/plugins/plugin_xep_0277.py |
diffstat | 2 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/plugin_misc_groupblog.py Tue Nov 24 16:21:18 2015 +0100 +++ b/src/plugins/plugin_misc_groupblog.py Tue Nov 24 23:18:32 2015 +0100 @@ -28,7 +28,7 @@ from wokkel import disco, data_form, iwokkel from wokkel import rsm from zope.interface import implements -from tools import common +from sat.tools import common # import uuid try:
--- a/src/plugins/plugin_xep_0277.py Tue Nov 24 16:21:18 2015 +0100 +++ b/src/plugins/plugin_xep_0277.py Tue Nov 24 23:18:32 2015 +0100 @@ -28,6 +28,7 @@ from sat.core import exceptions from sat.tools import xml_tools from sat.tools import sat_defer +from sat.tools import common # XXX: tmp.pubsub is actually use instead of wokkel version from wokkel import pubsub @@ -314,6 +315,10 @@ else: microblog_data['author_email'] = unicode(email_elt) + # categories + categories = (category_elt.getAttribute('term','') for category_elt in entry_elt.elements(NS_ATOM, 'category')) + common.iter2dict('tag', categories, microblog_data) + defer.returnValue(microblog_data) @defer.inlineCallbacks @@ -399,6 +404,11 @@ entry_elt.addElement('published', content=rfc3339.timestamp_from_tf(float(data.get('published', current_time)))) + ## categories ## + for tag in common.dict2iter("tag", data): + category_elt = entry_elt.addElement("category") + category_elt['term'] = tag + ## id ## entry_id = data.get('id', item_id) # FIXME: use a proper id (see XEP-0277 ยง7.1) entry_elt.addElement('id', content=entry_id) #