Mercurial > libervia-backend
comparison sat/plugins/plugin_xep_0163.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 | 003b8b4b56a7 |
children | ab2696e34d29 |
comparison
equal
deleted
inserted
replaced
2806:2400cad2dace | 2807:0b7ce5daee9b |
---|---|
25 log = getLogger(__name__) | 25 log = getLogger(__name__) |
26 from twisted.words.xish import domish | 26 from twisted.words.xish import domish |
27 | 27 |
28 from wokkel import disco, pubsub | 28 from wokkel import disco, pubsub |
29 from wokkel.formats import Mood | 29 from wokkel.formats import Mood |
30 from sat.tools.common import data_format | |
30 | 31 |
31 NS_USER_MOOD = "http://jabber.org/protocol/mood" | 32 NS_USER_MOOD = "http://jabber.org/protocol/mood" |
32 | 33 |
33 PLUGIN_INFO = { | 34 PLUGIN_INFO = { |
34 C.PI_NAME: "Personal Eventing Protocol Plugin", | 35 C.PI_NAME: "Personal Eventing Protocol Plugin", |
154 self.host.bridge.psEvent( | 155 self.host.bridge.psEvent( |
155 C.PS_PEP, | 156 C.PS_PEP, |
156 itemsEvent.sender.full(), | 157 itemsEvent.sender.full(), |
157 itemsEvent.nodeIdentifier, | 158 itemsEvent.nodeIdentifier, |
158 "MOOD", | 159 "MOOD", |
159 {"mood": mood.value or "", "text": mood.text or ""}, | 160 data_format.serialise({"mood": mood.value or "", "text": mood.text or ""}), |
160 profile, | 161 profile, |
161 ) | 162 ) |
162 | 163 |
163 def sendMood(self, data, profile): | 164 def sendMood(self, data, profile): |
164 """Send XEP-0107's User Mood | 165 """Send XEP-0107's User Mood |