component file sharing: comments metadata:

new <comments> element is added to file metadata, it contains the URL to the comments virtual node and the count of comments (this way client knows if it make sense to request comments or not).
Fixed triggers in plugin XEP-0264 (return value was missing).
New trigger in plugin XEP-0329 to allow component to add metadata (used here for comments url).
This commit is contained in:
Goffi 2018-03-16 18:43:11 +01:00
commit 76f39ca0c4

View file

@ -423,6 +423,11 @@ class XEP_0329(object):
@defer.inlineCallbacks
def _compGetFilesFromNodeCb(self, client, iq_elt, owner, node_path):
"""retrieve files from local files repository according to permissions
result stanza is then built and sent to requestor
@trigger XEP-0329_compGetFilesFromNode(client, iq_elt, owner, node_path, files_data): can be used to add data/elements
"""
peer_jid = jid.JID(iq_elt['from'])
try:
files_data = yield self.host.memory.getFiles(client, peer_jid=peer_jid, path=node_path, owner=owner)
@ -432,6 +437,8 @@ class XEP_0329(object):
iq_result_elt = xmlstream.toResponse(iq_elt, 'result')
query_elt = iq_result_elt.addElement((NS_FIS, 'query'))
query_elt[u'node'] = node_path
if not self.host.trigger.point(u'XEP-0329_compGetFilesFromNode', client, iq_elt, owner, node_path, files_data):
return
for file_data in files_data:
file_elt = self._jf.buildFileElementFromDict(file_data,
modified=file_data.get(u'modified', file_data[u'created']))