plugin XEP-0234: some cleaning + added triggers to allow plugins to change parsing/generation of <file> element
This commit is contained in:
parent
7faccbd03b
commit
29d9713462
1 changed files with 63 additions and 49 deletions
|
|
@ -311,11 +311,11 @@ class XEP_0329(object):
|
|||
name = os.path.basename(path)
|
||||
if os.path.isfile(path):
|
||||
size = os.path.getsize(path)
|
||||
media_type = mimetypes.guess_type(path, strict=False)[0]
|
||||
mime_type = mimetypes.guess_type(path, strict=False)[0]
|
||||
file_elt = self._jf.buildFileElement(name = name,
|
||||
size = size,
|
||||
media_type = media_type,
|
||||
date = os.path.getmtime(path))
|
||||
mime_type = mime_type,
|
||||
modified = os.path.getmtime(path))
|
||||
|
||||
query_elt.addChild(file_elt)
|
||||
# we don't specify hash as it would be too resource intensive to calculate it for all files
|
||||
|
|
@ -323,7 +323,7 @@ class XEP_0329(object):
|
|||
name_data = client._XEP_0329_names_data.setdefault(name, {})
|
||||
if path not in name_data:
|
||||
name_data[path] = {'size': size,
|
||||
'media_type': media_type,
|
||||
'mime_type': mime_type,
|
||||
'parent': parent_node}
|
||||
else:
|
||||
# we have a directory
|
||||
|
|
@ -435,7 +435,7 @@ class XEP_0329(object):
|
|||
query_elt[u'node'] = node_path
|
||||
for file_data in files_data:
|
||||
file_elt = self._jf.buildFileElementFromDict(file_data,
|
||||
date=file_data.get(u'modified', file_data[u'created']))
|
||||
modified=file_data.get(u'modified', file_data[u'created']))
|
||||
query_elt.addChild(file_elt)
|
||||
client.send(iq_result_elt)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue