comparison sat/plugins/plugin_comp_file_sharing.py @ 2929:e0429ff7f6b6

plugin comp file sharing: file sharing management first draft: the new "component file sharing management" plugin add ad-hoc commands to changes permission of one or several shared files, delete one or more files, or regenerate thumbnails. This is a temporary plugin to make file sharing through a component usable with other entities, but should be removed (at least permission management and file deletion) in the future if we move on a pubsub based solution.
author Goffi <goffi@goffi.org>
date Sun, 28 Apr 2019 09:00:51 +0200
parents 003b8b4b56a7
children ab2696e34d29
comparison
equal deleted inserted replaced
2928:c0f6fd75af5f 2929:e0429ff7f6b6
42 C.PI_MODES: [C.PLUG_MODE_COMPONENT], 42 C.PI_MODES: [C.PLUG_MODE_COMPONENT],
43 C.PI_TYPE: C.PLUG_TYPE_ENTRY_POINT, 43 C.PI_TYPE: C.PLUG_TYPE_ENTRY_POINT,
44 C.PI_PROTOCOLS: [], 44 C.PI_PROTOCOLS: [],
45 C.PI_DEPENDENCIES: [ 45 C.PI_DEPENDENCIES: [
46 "FILE", 46 "FILE",
47 "FILE_SHARING_MANAGEMENT",
47 "XEP-0231", 48 "XEP-0231",
48 "XEP-0234", 49 "XEP-0234",
49 "XEP-0260", 50 "XEP-0260",
50 "XEP-0261", 51 "XEP-0261",
51 "XEP-0264", 52 "XEP-0264",
217 ) 218 )
218 defer.returnValue(False) 219 defer.returnValue(False)
219 220
220 # we only use the first found file 221 # we only use the first found file
221 found_file = found_files[0] 222 found_file = found_files[0]
223 if found_file[u'type'] != C.FILE_TYPE_FILE:
224 raise TypeError(u"a file was expected, type is {type_}".format(
225 type_=found_file[u'type']))
222 file_hash = found_file[u"file_hash"] 226 file_hash = found_file[u"file_hash"]
223 file_path = os.path.join(self.files_path, file_hash) 227 file_path = os.path.join(self.files_path, file_hash)
224 file_data[u"hash_hasher"] = hasher = self._h.getHasher(found_file[u"hash_algo"]) 228 file_data[u"hash_hasher"] = hasher = self._h.getHasher(found_file[u"hash_algo"])
225 size = file_data[u"size"] = found_file[u"size"] 229 size = file_data[u"size"] = found_file[u"size"]
226 file_data[u"file_hash"] = file_hash 230 file_data[u"file_hash"] = file_hash