From 8cdad276bfc6f957b0039bb63f0687b2d6f92b29 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Philipp=20H=C3=B6rist?= <philipp@hoerist.com>
Date: Wed, 24 Jan 2018 17:05:41 +0100
Subject: [PATCH] Fix httpupload when using multiple accounts

Fixes #8865
---
 gajim/common/connection_handlers.py | 2 +-
 gajim/common/httpupload.py          | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/gajim/common/connection_handlers.py b/gajim/common/connection_handlers.py
index 3d3c2d1af6..f867a36025 100644
--- a/gajim/common/connection_handlers.py
+++ b/gajim/common/connection_handlers.py
@@ -1261,7 +1261,7 @@ ConnectionHTTPUpload):
         ConnectionPubSub.__init__(self)
         ConnectionPEP.__init__(self, account=self.name, dispatcher=self,
             pubsub_connection=self)
-        ConnectionHTTPUpload.__init__(self, account=self.name)
+        ConnectionHTTPUpload.__init__(self)
 
         # Handle presences BEFORE caps
         app.nec.register_incoming_event(PresenceReceivedEvent)
diff --git a/gajim/common/httpupload.py b/gajim/common/httpupload.py
index 49ea37b587..f9ae2232cc 100644
--- a/gajim/common/httpupload.py
+++ b/gajim/common/httpupload.py
@@ -46,8 +46,7 @@ class ConnectionHTTPUpload:
     Implement HTTP File Upload
     (XEP-0363, https://xmpp.org/extensions/xep-0363.html)
     """
-    def __init__(self, account):
-        self.name = account
+    def __init__(self):
         self.encrypted_upload = False
         self.component = None
         self.max_file_size = None  # maximum file size in bytes
@@ -84,6 +83,9 @@ class ConnectionHTTPUpload:
             return
 
         account = event.conn.name
+        if account != self.name:
+            return
+
         self.component = event.jid
 
         for form in event.data:
@@ -102,6 +104,8 @@ class ConnectionHTTPUpload:
                      account, self.max_file_size/(1024*1024))
 
     def handle_outgoing_stanza(self, event):
+        if event.conn.name != self.name:
+            return
         message = event.msg_iq.getTagData('body')
         if message and message in self.messages:
             self.messages.remove(message)
-- 
GitLab