plugins blog import, tickets import, XEP-0277: fixed call to getCommentsService (it is now returning a Deferred)

This commit is contained in:
Goffi 2017-11-16 07:31:00 +01:00
commit a014e6a873
3 changed files with 8 additions and 5 deletions

View file

@ -121,24 +121,26 @@ class BlogImportPlugin(object):
return mb_data
@defer.inlineCallbacks
def importSubItems(self, client, item_import_data, mb_data, session, options):
# comments data
if len(item_import_data['comments']) != 1:
raise NotImplementedError(u"can't manage multiple comment links")
allow_comments = C.bool(mb_data.get('allow_comments', C.BOOL_FALSE))
if allow_comments:
comments_service, comments_node = self._m.getCommentsService(client), self._m.getCommentsNode(mb_data['id'])
comments_service = yield self._m.getCommentsService(client)
comments_node = self._m.getCommentsNode(mb_data['id'])
mb_data['comments_service'] = comments_service.full()
mb_data['comments_node'] = comments_node
recurse_kwargs = {
'items_import_data':item_import_data['comments'][0],
'service':comments_service,
'node':comments_node}
return recurse_kwargs
defer.returnValue(recurse_kwargs)
else:
if item_import_data['comments'][0]:
raise exceptions.DataError(u"allow_comments set to False, but comments are there")
return None
defer.returnValue(None)
def publishItem(self, client, mb_data, service, node, session):
log.debug(u"uploading item [{id}]: {title}".format(id=mb_data['id'], title=mb_data.get('title','')))

View file

@ -123,7 +123,8 @@ class TicketsImportPlugin(object):
# TODO: handle "private" metadata, to have non public access for node
# TODO: node access/publish model should be customisable
comments = ticket_data.get('comments', [])
service, node = self._m.getCommentsService(client), self._m.getCommentsNode(session['root_node'] + u'_' + ticket_data['id'])
service = yield self._m.getCommentsService(client)
node = self._m.getCommentsNode(session['root_node'] + u'_' + ticket_data['id'])
node_options = {self._p.OPT_ACCESS_MODEL: self._p.ACCESS_OPEN,
self._p.OPT_PERSIST_ITEMS: 1,
self._p.OPT_MAX_ITEMS: -1,

View file

@ -541,7 +541,7 @@ class XEP_0277(object):
try:
comments_service = jid.JID(mb_data['comments_service'])
except KeyError:
comments_service = self.getCommentsService(client, service)
comments_service = yield self.getCommentsService(client, service)
try:
yield self._p.createNode(client, comments_service, comments_node, options)