Mercurial > libervia-backend
changeset 3515:2dce411c2647
plugin misc forums: use rich content in createTopic
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 01 May 2021 18:23:42 +0200 |
parents | 6d9c9e2dca0a |
children | e47aa1fb7b24 |
files | sat/plugins/plugin_misc_forums.py |
diffstat | 1 files changed, 10 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/sat/plugins/plugin_misc_forums.py Sat May 01 18:22:53 2021 +0200 +++ b/sat/plugins/plugin_misc_forums.py Sat May 01 18:23:42 2021 +0200 @@ -272,20 +272,21 @@ def _createTopic(self, service, node, mb_data, profile_key): client = self.host.getClient(profile_key) - return self.createTopic(client, jid.JID(service), node, mb_data) + return defer.ensureDeferred( + self.createTopic(client, jid.JID(service), node, mb_data) + ) - @defer.inlineCallbacks - def createTopic(self, client, service, node, mb_data): + async def createTopic(self, client, service, node, mb_data): try: title = mb_data['title'] - if not 'content' in mb_data: - raise KeyError('content') + content = mb_data.pop('content') except KeyError as e: raise exceptions.DataError("missing mandatory data: {key}".format(key=e.args[0])) - + else: + mb_data["content_rich"] = content topic_node = FORUM_TOPIC_NODE_TPL.format(node=node, uuid=shortuuid.uuid()) - yield self._p.createNode(client, service, topic_node, self._node_options) - self._m.send(client, mb_data, service, topic_node) + await self._p.createNode(client, service, topic_node, self._node_options) + await self._m.send(client, mb_data, service, topic_node) topic_uri = uri.buildXMPPUri('pubsub', subtype='microblog', path=service.full(), @@ -294,4 +295,4 @@ topic_elt['uri'] = topic_uri topic_elt['author'] = client.jid.userhost() topic_elt.addElement('title', content = title) - yield self._p.sendItem(client, service, node, topic_elt) + await self._p.sendItem(client, service, node, topic_elt)