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.
This commit is contained in:
parent
6a5de4440e
commit
cb2144bdf4
1 changed files with 13 additions and 4 deletions
|
|
@ -355,7 +355,7 @@ class FileSharing:
|
|||
self._h = self.host.plugins["XEP-0300"]
|
||||
self._t = self.host.plugins["XEP-0264"]
|
||||
self._hu = self.host.plugins["XEP-0363"]
|
||||
self._hu.registerHandler(self._onHTTPUpload)
|
||||
self._hu.registerHandler(self._on_http_upload)
|
||||
self.host.trigger.add("FILE_getDestDir", self._getDestDirTrigger)
|
||||
self.host.trigger.add(
|
||||
"XEP-0234_fileSendingRequest", self._fileSendingRequestTrigger, priority=1000
|
||||
|
|
@ -393,6 +393,9 @@ class FileSharing:
|
|||
return Comments_handler(self)
|
||||
|
||||
def profileConnecting(self, client):
|
||||
# we activate HTTP upload
|
||||
client.enabled_features.add("XEP-0363")
|
||||
|
||||
self.init()
|
||||
public_base_url = self.host.memory.getConfig(
|
||||
'component file-sharing', 'http_upload_public_facing_url')
|
||||
|
|
@ -632,7 +635,7 @@ class FileSharing:
|
|||
except KeyError:
|
||||
log.error(f"trying to purge an inexisting upload slot ({upload_id})")
|
||||
|
||||
async def _onHTTPUpload(self, client, request):
|
||||
async def _on_http_upload(self, client, request):
|
||||
# filename should be already cleaned, but it's better to double check
|
||||
assert '/' not in request.filename
|
||||
# client._file_sharing_allowed_hosts is set in plugin XEP-0329
|
||||
|
|
|
|||
Loading…
Reference in a new issue