comparison sat/plugins/plugin_xep_0363.py @ 4021:412b99c29d83

core (xmpp), component file sharing, plugin XEP-0363: `enabled_features` + HTTP Upload: add a mechanism to explicitely enable some features in components, and use it to enable HTTP Upload only if it's explicitely enabled.
author Goffi <goffi@goffi.org>
date Thu, 23 Mar 2023 15:38:07 +0100
parents 0ff265725489
children 524856bd7b19
comparison
equal deleted inserted replaced
4020:d8a1219e913f 4021:412b99c29d83
431 431
432 def __init__(self, plugin_parent): 432 def __init__(self, plugin_parent):
433 self.plugin_parent = plugin_parent 433 self.plugin_parent = plugin_parent
434 434
435 def connectionInitialized(self): 435 def connectionInitialized(self):
436 if self.parent.is_component: 436 if ((self.parent.is_component
437 and PLUGIN_INFO[C.PI_IMPORT_NAME] in self.parent.enabled_features)):
437 self.xmlstream.addObserver( 438 self.xmlstream.addObserver(
438 IQ_HTTP_UPLOAD_REQUEST, self.plugin_parent.onComponentRequest, 439 IQ_HTTP_UPLOAD_REQUEST, self.plugin_parent.onComponentRequest,
439 client=self.parent 440 client=self.parent
440 ) 441 )
441 442
442 def getDiscoInfo(self, requestor, target, nodeIdentifier=""): 443 def getDiscoInfo(self, requestor, target, nodeIdentifier=""):
443 return [disco.DiscoFeature(NS_HTTP_UPLOAD)] 444 if ((self.parent.is_component
445 and not PLUGIN_INFO[C.PI_IMPORT_NAME] in self.parent.enabled_features)):
446 return []
447 else:
448 return [disco.DiscoFeature(NS_HTTP_UPLOAD)]
444 449
445 def getDiscoItems(self, requestor, target, nodeIdentifier=""): 450 def getDiscoItems(self, requestor, target, nodeIdentifier=""):
446 return [] 451 return []