comparison src/plugins/plugin_xep_0277.py @ 2390:f57a8eaec8ed

plugins import, tickets import, bugzilla import: comments handling: - comments are put in "comments" key in import data, it's a list of microblog data - in resulting item, the comments uri is put in comments_uri field - (plugin import) root_service and root_node are kept in session - (plugin ticket) reporter name is now in "reporter" key instead of "reporter_name" - (plugin bugizlla): if not reporter name is found, first part of email address is used
author Goffi <goffi@goffi.org>
date Fri, 20 Oct 2017 08:48:41 +0200
parents 72cbb6478f97
children 70399d1acb47
comparison
equal deleted inserted replaced
2389:5675af905725 2390:f57a8eaec8ed
660 660
661 If the node already exists, it change options 661 If the node already exists, it change options
662 @param access: Node access model, according to xep-0060 #4.5 662 @param access: Node access model, according to xep-0060 #4.5
663 @param profile_key: profile key 663 @param profile_key: profile key
664 """ 664 """
665 # FIXME: check if this mehtod is needed, deprecate it if not
665 client = self.host.getClient(profile_key) 666 client = self.host.getClient(profile_key)
666 667
667 _jid, xmlstream = self.host.getJidNStream(profile_key)
668 if not _jid:
669 log.error(_(u"Can't find profile's jid"))
670 return
671 _options = {self._p.OPT_ACCESS_MODEL: access, self._p.OPT_PERSIST_ITEMS: 1, self._p.OPT_MAX_ITEMS: -1, self._p.OPT_DELIVER_PAYLOADS: 1, self._p.OPT_SEND_ITEM_SUBSCRIBE: 1} 668 _options = {self._p.OPT_ACCESS_MODEL: access, self._p.OPT_PERSIST_ITEMS: 1, self._p.OPT_MAX_ITEMS: -1, self._p.OPT_DELIVER_PAYLOADS: 1, self._p.OPT_SEND_ITEM_SUBSCRIBE: 1}
672 669
673 def cb(result): 670 def cb(result):
674 #Node is created with right permission 671 #Node is created with right permission
675 log.debug(_(u"Microblog node has now access %s") % access) 672 log.debug(_(u"Microblog node has now access %s") % access)
681 678
682 def err_cb(s_error): 679 def err_cb(s_error):
683 #If the node already exists, the condition is "conflict", 680 #If the node already exists, the condition is "conflict",
684 #else we have an unmanaged error 681 #else we have an unmanaged error
685 if s_error.value.condition == 'conflict': 682 if s_error.value.condition == 'conflict':
686 #d = self.host.plugins["XEP-0060"].deleteNode(client, _jid.userhostJID(), NS_MICROBLOG) 683 #d = self.host.plugins["XEP-0060"].deleteNode(client, client.jid.userhostJID(), NS_MICROBLOG)
687 #d.addCallback(lambda x: create_node().addCallback(cb).addErrback(fatal_err)) 684 #d.addCallback(lambda x: create_node().addCallback(cb).addErrback(fatal_err))
688 change_node_options().addCallback(cb).addErrback(fatal_err) 685 change_node_options().addCallback(cb).addErrback(fatal_err)
689 else: 686 else:
690 fatal_err(s_error) 687 fatal_err(s_error)
691 688
692 def create_node(): 689 def create_node():
693 return self._p.createNode(client, _jid.userhostJID(), NS_MICROBLOG, _options) 690 return self._p.createNode(client, client.jid.userhostJID(), NS_MICROBLOG, _options)
694 691
695 def change_node_options(): 692 def change_node_options():
696 return self._p.setOptions(_jid.userhostJID(), NS_MICROBLOG, _jid.userhostJID(), _options, profile_key=profile_key) 693 return self._p.setOptions(client.jid.userhostJID(), NS_MICROBLOG, client.jid.userhostJID(), _options, profile_key=profile_key)
697 694
698 create_node().addCallback(cb).addErrback(err_cb) 695 create_node().addCallback(cb).addErrback(err_cb)
699 696
700 ## methods to manage several stanzas/jids at once ## 697 ## methods to manage several stanzas/jids at once ##
701 698