Commit 328ceedd authored by Philipp Hörist's avatar Philipp Hörist

Fix rejecting file transfer

parent 200428c0
Pipeline #3668 passed with stages
in 2 minutes and 39 seconds
......@@ -538,7 +538,7 @@ class JingleSession:
# If we are not receiving a file
# Check if there's already a session with this user:
if contents[0].media != 'file':
for session in self.connection.get_module('Jingle').iter_jingle_sessions(self.peerjid):
for session in self.connection.get_module('Jingle').get_jingle_sessions(self.peerjid):
if session is not self:
reason = nbxmpp.Node('reason')
alternative_session = reason.setTag('alternative-session')
......
......@@ -179,10 +179,9 @@ class Bytestream(BaseModule):
if not app.account_is_connected(self._account):
return
if file_props.sid in self._sessions:
jingle = self._sessions[file_props.sid]
jingle.cancel_session()
return
for session in self._con.get_module('Jingle').get_jingle_sessions(
None, file_props.sid):
session.cancel_session()
def send_success_connect_reply(self, streamhost):
"""
......
......@@ -230,16 +230,16 @@ class Jingle(BaseModule):
return 'sha-256'
return None
def iter_jingle_sessions(self, jid, sid=None, media=None):
def get_jingle_sessions(self, jid, sid=None, media=None):
if sid:
return (session for session in self._sessions.values() if \
session.sid == sid)
sessions = (session for session in self._sessions.values() if \
session.peerjid == jid)
return [session for session in self._sessions.values() if \
session.sid == sid]
sessions = [session for session in self._sessions.values() if \
session.peerjid == jid]
if media:
if media not in ('audio', 'video', 'file'):
return tuple()
return (session for session in sessions if session.get_content(media))
return []
return [session for session in sessions if session.get_content(media)]
return sessions
def set_file_info(self, file_):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment