Mercurial > libervia-backend
comparison sat/plugins/plugin_misc_forums.py @ 3549:3fd60beb9b92
plugin forums: use serialised data for extra in forumTopicsGet
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 06 Jun 2021 19:35:19 +0200 |
parents | 2dce411c2647 |
children | edc79cefe968 |
comparison
equal
deleted
inserted
replaced
3548:13e7ef106589 | 3549:3fd60beb9b92 |
---|---|
19 | 19 |
20 from sat.core.i18n import _ | 20 from sat.core.i18n import _ |
21 from sat.core.constants import Const as C | 21 from sat.core.constants import Const as C |
22 from sat.core import exceptions | 22 from sat.core import exceptions |
23 from sat.core.log import getLogger | 23 from sat.core.log import getLogger |
24 from sat.tools.common import uri | 24 from sat.tools.common import uri, data_format |
25 from twisted.words.protocols.jabber import jid | 25 from twisted.words.protocols.jabber import jid |
26 from twisted.words.xish import domish | 26 from twisted.words.xish import domish |
27 from twisted.internet import defer | 27 from twisted.internet import defer |
28 import shortuuid | 28 import shortuuid |
29 import json | 29 import json |
71 host.bridge.addMethod("forumsSet", ".plugin", | 71 host.bridge.addMethod("forumsSet", ".plugin", |
72 in_sign='sssss', out_sign='', | 72 in_sign='sssss', out_sign='', |
73 method=self._set, | 73 method=self._set, |
74 async_=True) | 74 async_=True) |
75 host.bridge.addMethod("forumTopicsGet", ".plugin", | 75 host.bridge.addMethod("forumTopicsGet", ".plugin", |
76 in_sign='ssa{ss}s', out_sign='(aa{ss}a{ss})', | 76 in_sign='ssa{ss}s', out_sign='(aa{ss}s)', |
77 method=self._getTopics, | 77 method=self._getTopics, |
78 async_=True) | 78 async_=True) |
79 host.bridge.addMethod("forumTopicCreate", ".plugin", | 79 host.bridge.addMethod("forumTopicCreate", ".plugin", |
80 in_sign='ssa{ss}s', out_sign='', | 80 in_sign='ssa{ss}s', out_sign='', |
81 method=self._createTopic, | 81 method=self._createTopic, |
247 | 247 |
248 def _getTopics(self, service, node, extra=None, profile_key=C.PROF_KEY_NONE): | 248 def _getTopics(self, service, node, extra=None, profile_key=C.PROF_KEY_NONE): |
249 client = self.host.getClient(profile_key) | 249 client = self.host.getClient(profile_key) |
250 extra = self._p.parseExtra(extra) | 250 extra = self._p.parseExtra(extra) |
251 d = self.getTopics(client, jid.JID(service), node, rsm_request=extra.rsm_request, extra=extra.extra) | 251 d = self.getTopics(client, jid.JID(service), node, rsm_request=extra.rsm_request, extra=extra.extra) |
252 d.addCallback(lambda topics_metadata: (topics_metadata[0], {k: str(v) for k,v in topics_metadata[1].items()})) | 252 d.addCallback( |
253 lambda topics_data: (topics_data[0], data_format.serialise(topics_data[1])) | |
254 ) | |
253 return d | 255 return d |
254 | 256 |
255 @defer.inlineCallbacks | 257 @defer.inlineCallbacks |
256 def getTopics(self, client, service, node, rsm_request=None, extra=None): | 258 def getTopics(self, client, service, node, rsm_request=None, extra=None): |
257 """Retrieve topics data | 259 """Retrieve topics data |