plugin XEP-0329, core(xmpp): moved _compParseJids to SatXMPPComponent:
This method to retrieve owner and peer JID from an element is generally useful for components, thus it has been moved. The part to retrieve owner JID from local JID has been splitted in its own `getOwnerFromJid` method.
This commit is contained in:
parent
93e1250a59
commit
50df9e6537
1 changed files with 46 additions and 19 deletions
|
|
@ -590,24 +590,10 @@ class XEP_0329(object):
|
|||
@param iq_elt(domish.Element): IQ stanza of the FIS request
|
||||
@return (tuple[jid.JID, jid.JID]): peer_jid and owner
|
||||
"""
|
||||
to_jid = jid.JID(iq_elt['to'])
|
||||
if to_jid.user:
|
||||
user = self.host.plugins['XEP-0106'].unescape(to_jid.user)
|
||||
if '@' in user:
|
||||
# a full jid is specified
|
||||
owner = jid.JID(user)
|
||||
else:
|
||||
# only user part is specified, we use our own host to build the full jid
|
||||
owner = jid.JID(None, (user, client.host, None))
|
||||
else:
|
||||
owner = jid.JID(iq_elt["from"]).userhostJID()
|
||||
|
||||
peer_jid = jid.JID(iq_elt["from"])
|
||||
return peer_jid, owner
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _compGetRootNodesCb(self, client, iq_elt):
|
||||
peer_jid, owner = self._compParseJids(client, iq_elt)
|
||||
peer_jid, owner = client.getOwnerAndPeer(iq_elt)
|
||||
files_data = yield self.host.memory.getFiles(
|
||||
client,
|
||||
peer_jid=peer_jid,
|
||||
|
|
@ -632,7 +618,7 @@ class XEP_0329(object):
|
|||
files_data):
|
||||
can be used to add data/elements
|
||||
"""
|
||||
peer_jid, owner = self._compParseJids(client, iq_elt)
|
||||
peer_jid, owner = client.getOwnerAndPeer(iq_elt)
|
||||
try:
|
||||
files_data = yield self.host.memory.getFiles(
|
||||
client, peer_jid=peer_jid, path=node_path, owner=owner
|
||||
|
|
@ -733,7 +719,7 @@ class XEP_0329(object):
|
|||
# affiliations #
|
||||
|
||||
async def _parseElement(self, client, iq_elt, element, namespace):
|
||||
peer_jid, owner = self._compParseJids(client, iq_elt)
|
||||
peer_jid, owner = client.getOwnerAndPeer(iq_elt)
|
||||
elt = next(iq_elt.elements(namespace, element))
|
||||
path = Path("/", elt['path'])
|
||||
if len(path.parts) < 2:
|
||||
|
|
@ -838,7 +824,7 @@ class XEP_0329(object):
|
|||
return
|
||||
except RootPathException:
|
||||
# if root path is requested, we only get owner affiliation
|
||||
peer_jid, owner = self._compParseJids(client, iq_elt)
|
||||
peer_jid, owner = client.getOwnerAndPeer(iq_elt)
|
||||
is_owner = peer_jid.userhostJID() == owner
|
||||
affiliations = {owner: 'owner'}
|
||||
except exceptions.NotFound:
|
||||
|
|
@ -1080,7 +1066,7 @@ class XEP_0329(object):
|
|||
defer.ensureDeferred(self.onComponentCreateDir(client, iq_elt))
|
||||
|
||||
async def onComponentCreateDir(self, client, iq_elt):
|
||||
peer_jid, owner = self._compParseJids(client, iq_elt)
|
||||
peer_jid, owner = client.getOwnerAndPeer(iq_elt)
|
||||
if peer_jid.host not in client._file_sharing_allowed_hosts:
|
||||
client.sendError(iq_elt, 'forbidden')
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in a new issue