diff sat_frontends/quick_frontend/quick_app.py @ 2807:0b7ce5daee9b

plugin XEP-0277: blog items data are now entirely serialised before going to bridge: So far, and for historical reasons, blog items data where serialised using a unicode: unicode dict, which was causing trouble for many types of values (timestamps, booleans, lists). This patch changes it by serialising the whole items before going to bridge, and deserialising it when going back. This way, complex data can be used easily in items. This impact psEvent and serItemsData* methods which are renamed transItemsData* because there are not always serialising anymore (a new argument "serialise" allows to specify it). When editing a blog post in jp, metadata are now more easy to manipulate, specially lists like tags.
author Goffi <goffi@goffi.org>
date Sat, 23 Feb 2019 18:59:00 +0100
parents 441b536e28ed
children 649cb3fd7711
line wrap: on
line diff
--- a/sat_frontends/quick_frontend/quick_app.py	Wed Feb 20 19:42:35 2019 +0100
+++ b/sat_frontends/quick_frontend/quick_app.py	Sat Feb 23 18:59:00 2019 +0100
@@ -988,8 +988,9 @@
         @param service_s (unicode): pubsub service
         @param node (unicode): pubsub node
         @param event_type (unicode): event type (one of C.PUBLISH, C.RETRACT, C.DELETE)
-        @param data (dict): event data
+        @param data (serialised_dict): event data
         """
+        data = data_format.deserialise(data)
         service_s = jid.JID(service_s)
 
         if category == C.PS_MICROBLOG and self.MB_HANDLER:
@@ -997,9 +998,9 @@
                 if not "content" in data:
                     log.warning("No content found in microblog data")
                     return
-                _groups = (
-                    set(data_format.dict2iter("group", data)) or None
-                )  # FIXME: check if [] make sense (instead of None)
+
+                # FIXME: check if [] make sense (instead of None)
+                _groups = data.get("group")
 
                 for wid in self.widgets.getWidgets(quick_blog.QuickBlog):
                     wid.addEntryIfAccepted(service_s, node, data, _groups, profile)