changeset 770:64dd7c0f4feb

plugin groupblog, XEP-0277: store both published and updated timestamps
author souliane <souliane@mailoo.org>
date Thu, 19 Dec 2013 13:54:40 +0100
parents 8b6137f7b4e1
children bfabeedbf32e
files src/plugins/plugin_misc_groupblog.py src/plugins/plugin_xep_0277.py
diffstat 2 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/plugin_misc_groupblog.py	Wed Dec 18 15:37:30 2013 +0100
+++ b/src/plugins/plugin_misc_groupblog.py	Thu Dec 19 13:54:40 2013 +0100
@@ -411,6 +411,8 @@
             if comments:
                 node = self.getNodeName(client.jid)
             mblog_data['id'] = str(item_id)
+            if 'published' in extra:
+                mblog_data['published'] = extra['published']
             if extra.get('allow_comments', 'False').lower() == 'true':
                 comments_node = self.host.plugins["XEP-0277"].parseCommentUrl(comments)[1]
                 # we could use comments_node directly but it's safer to rebuild it
--- a/src/plugins/plugin_xep_0277.py	Wed Dec 18 15:37:30 2013 +0100
+++ b/src/plugins/plugin_xep_0277.py	Thu Dec 19 13:54:40 2013 +0100
@@ -108,7 +108,11 @@
                 microblog_data['content'] = _entry.title.text
             if len(_entry.authors):
                 microblog_data['author'] = _entry.authors[0].name.text
-            microblog_data['timestamp'] = str(int(_entry.updated.tf))
+            microblog_data['updated'] = str(int(_entry.updated.tf))
+            try:
+                microblog_data['published'] = str(int(_entry.published.tf))
+            except (KeyError, TypeError):
+                microblog_data['published'] = microblog_data['updated']
             microblog_data['id'] = item['id']
             for link in _entry.links:
                 try:
@@ -172,7 +176,8 @@
 
         _entry.author = atom.Author()
         _entry.author.name = data.get('author', self.host.getJidNStream(profile)[0].userhost()).encode('utf-8')
-        _entry.updated = float(data.get('timestamp', time()))
+        _entry.updated = float(data.get('updated', time()))
+        _entry.published = float(data.get('published', time()))
         entry_id = data.get('id', str(_uuid))
         _entry.id = entry_id
         if 'comments' in data: