Mercurial > libervia-backend
changeset 2518:e4de2f16a284
core (memory): use bare jid for owner in setFiles:
this makes files unusable for MUCs private conversations, but it doesn't make much sense to use it in this case.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 14 Mar 2018 08:07:24 +0100 (2018-03-14) |
parents | cd7a53c31eb6 |
children | 353880a5c363 |
files | src/memory/memory.py |
diffstat | 1 files changed, 8 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/memory/memory.py Wed Mar 14 08:05:55 2018 +0100 +++ b/src/memory/memory.py Wed Mar 14 08:07:24 2018 +0100 @@ -1186,6 +1186,8 @@ """ if peer_jid is None and perms_to_check or perms_to_check is None and peer_jid: raise exceptions.InternalError('if you want to disable permission check, both peer_jid and perms_to_check must be None') + if owner is not None: + owner = owner.userhostJID() if path is not None: # permission are checked by _getParentDir parent, remaining_path_elts = yield self._getParentDir(client, path, parent, namespace, owner, peer_jid, perms_to_check) @@ -1244,7 +1246,7 @@ @param created(int): UNIX time of creation @param modified(int,None): UNIX time of last modification, or None to use created date @param owner(jid.JID, None): jid of the owner of the file (mainly useful for component) - will be used to check permission. + will be used to check permission (only bare jid is used, don't use with MUC). Use None to ignore permission (perms_to_check must be None too) @param access(dict, None): serialisable dictionary with access rules. None (or empty dict) to use private access, i.e. allow only profile's jid to access the file @@ -1276,11 +1278,11 @@ if type_ == C.FILE_TYPE_DIRECTORY: if any(version, file_hash, size, mime_type): raise ValueError(u"version, file_hash, size and mime_type can't be set for a directory") + if owner is not None: + owner = owner.userhostJID() if path is not None: - if peer_jid is None: - peer_jid = owner - # _getParentDir will check permissions if peer_jid is set + # _getParentDir will check permissions if peer_jid is set, so we use owner parent, remaining_path_elts = yield self._getParentDir(client, path, parent, namespace, owner, owner, perms_to_check) # if remaining directories don't exist, we have to create them for new_dir in remaining_path_elts: @@ -1288,7 +1290,7 @@ yield self.storage.setFile(client, name=new_dir, file_id=new_dir_id, version=u'', parent=parent, type_=C.FILE_TYPE_DIRECTORY, namespace=namespace, created=time.time(), - owner=owner.userhostJID() if owner else None, + owner=owner, access=access, extra={}) parent = new_dir_id elif parent is None: @@ -1297,7 +1299,7 @@ yield self.storage.setFile(client, file_id=file_id, version=version, parent=parent, type_=type_, file_hash=file_hash, hash_algo=hash_algo, name=name, size=size, namespace=namespace, mime_type=mime_type, created=created, modified=modified, - owner=owner.userhostJID() if owner else None, + owner=owner, access=access, extra=extra) ## Misc ##