plugin misc forums: use rich content in createTopic
This commit is contained in:
parent
2cfffc5f6c
commit
6456df58fb
1 changed files with 10 additions and 9 deletions
|
|
@ -272,20 +272,21 @@ class forums(object):
|
||||||
|
|
||||||
def _createTopic(self, service, node, mb_data, profile_key):
|
def _createTopic(self, service, node, mb_data, profile_key):
|
||||||
client = self.host.getClient(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
|
async def createTopic(self, client, service, node, mb_data):
|
||||||
def createTopic(self, client, service, node, mb_data):
|
|
||||||
try:
|
try:
|
||||||
title = mb_data['title']
|
title = mb_data['title']
|
||||||
if not 'content' in mb_data:
|
content = mb_data.pop('content')
|
||||||
raise KeyError('content')
|
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
raise exceptions.DataError("missing mandatory data: {key}".format(key=e.args[0]))
|
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())
|
topic_node = FORUM_TOPIC_NODE_TPL.format(node=node, uuid=shortuuid.uuid())
|
||||||
yield self._p.createNode(client, service, topic_node, self._node_options)
|
await self._p.createNode(client, service, topic_node, self._node_options)
|
||||||
self._m.send(client, mb_data, service, topic_node)
|
await self._m.send(client, mb_data, service, topic_node)
|
||||||
topic_uri = uri.buildXMPPUri('pubsub',
|
topic_uri = uri.buildXMPPUri('pubsub',
|
||||||
subtype='microblog',
|
subtype='microblog',
|
||||||
path=service.full(),
|
path=service.full(),
|
||||||
|
|
@ -294,4 +295,4 @@ class forums(object):
|
||||||
topic_elt['uri'] = topic_uri
|
topic_elt['uri'] = topic_uri
|
||||||
topic_elt['author'] = client.jid.userhost()
|
topic_elt['author'] = client.jid.userhost()
|
||||||
topic_elt.addElement('title', content = title)
|
topic_elt.addElement('title', content = title)
|
||||||
yield self._p.sendItem(client, service, node, topic_elt)
|
await self._p.sendItem(client, service, node, topic_elt)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue