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

Fix rejecting file transfer

parent 200428c0
...@@ -538,7 +538,7 @@ def __on_session_initiate(self, stanza, jingle, error, action): ...@@ -538,7 +538,7 @@ def __on_session_initiate(self, stanza, jingle, error, action):
# If we are not receiving a file # If we are not receiving a file
# Check if there's already a session with this user: # Check if there's already a session with this user:
if contents[0].media != 'file': 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: if session is not self:
reason = nbxmpp.Node('reason') reason = nbxmpp.Node('reason')
alternative_session = reason.setTag('alternative-session') alternative_session = reason.setTag('alternative-session')
......
...@@ -179,10 +179,9 @@ def send_file_rejection(self, file_props, code='403', typ=None): ...@@ -179,10 +179,9 @@ def send_file_rejection(self, file_props, code='403', typ=None):
if not app.account_is_connected(self._account): if not app.account_is_connected(self._account):
return return
if file_props.sid in self._sessions: for session in self._con.get_module('Jingle').get_jingle_sessions(
jingle = self._sessions[file_props.sid] None, file_props.sid):
jingle.cancel_session() session.cancel_session()
return
def send_success_connect_reply(self, streamhost): def send_success_connect_reply(self, streamhost):
""" """
......
...@@ -230,16 +230,16 @@ def __hash_support(self, contact): ...@@ -230,16 +230,16 @@ def __hash_support(self, contact):
return 'sha-256' return 'sha-256'
return None return None
def iter_jingle_sessions(self, jid, sid=None, media=None): def get_jingle_sessions(self, jid, sid=None, media=None):
if sid: if sid:
return (session for session in self._sessions.values() if \ return [session for session in self._sessions.values() if \
session.sid == sid) session.sid == sid]
sessions = (session for session in self._sessions.values() if \ sessions = [session for session in self._sessions.values() if \
session.peerjid == jid) session.peerjid == jid]
if media: if media:
if media not in ('audio', 'video', 'file'): if media not in ('audio', 'video', 'file'):
return tuple() return []
return (session for session in sessions if session.get_content(media)) return [session for session in sessions if session.get_content(media)]
return sessions return sessions
def set_file_info(self, file_): 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