# HG changeset patch # User Goffi # Date 1619886222 -7200 # Node ID 2dce411c2647fd8d1b8e9dbc7519dc5685456e1c # Parent 6d9c9e2dca0a46aa2d456c49da4b8618a2044e21 plugin misc forums: use rich content in createTopic diff -r 6d9c9e2dca0a -r 2dce411c2647 sat/plugins/plugin_misc_forums.py --- 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)