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.
This commit is contained in:
parent
41ce2e27e6
commit
d4ed57dadc
1 changed files with 8 additions and 6 deletions
|
|
@ -1186,6 +1186,8 @@ class Memory(object):
|
|||
"""
|
||||
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 @@ class Memory(object):
|
|||
@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 @@ class Memory(object):
|
|||
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 @@ class Memory(object):
|
|||
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 @@ class Memory(object):
|
|||
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 ##
|
||||
|
|
|
|||
Loading…
Reference in a new issue