plugin XEP-0277: tags are handled through atom categories

This commit is contained in:
Goffi 2015-11-24 23:18:32 +01:00
commit 08c4e34815
2 changed files with 11 additions and 1 deletions

View file

@ -28,7 +28,7 @@ from sat.core import exceptions
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:

View file

@ -28,6 +28,7 @@ from twisted.python import failure
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 @@ class XEP_0277(object):
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 @@ class XEP_0277(object):
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) #