From 6f7648c8da79a47c9f7e73d569f893a7ae546505 Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Thu, 21 Apr 2011 15:00:32 +0200
Subject: [PATCH] don't allow to join a groupchat if we have a contact with the
 same JID. Fixes #5799

---
 src/dialogs.py       | 11 ++++-------
 src/gui_interface.py |  8 +++++++-
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/dialogs.py b/src/dialogs.py
index f2f3fc0f05..f7b6b5f0b9 100644
--- a/src/dialogs.py
+++ b/src/dialogs.py
@@ -2335,13 +2335,10 @@ class JoinGroupchatWindow:
                     _('The group chat Jabber ID has not allowed characters.'))
             return
 
-        if gajim.interface.msg_win_mgr.has_window(room_jid, self.account):
-            ctrl = gajim.interface.msg_win_mgr.get_gc_control(room_jid,
-                    self.account)
-            if ctrl.type_id != message_control.TYPE_GC:
-                ErrorDialog(_('This is not a group chat'),
-                        _('%s is not the name of a group chat.') % room_jid)
-                return
+        if gajim.contacts.get_contact(self.account, room_jid):
+            ErrorDialog(_('This is not a group chat'),
+                _('%s is not the name of a group chat.') % room_jid)
+            return
         if room_jid in self.recently_groupchat:
             self.recently_groupchat.remove(room_jid)
         self.recently_groupchat.insert(0, room_jid)
diff --git a/src/gui_interface.py b/src/gui_interface.py
index 0bd4776f2e..a866c7c02f 100644
--- a/src/gui_interface.py
+++ b/src/gui_interface.py
@@ -2666,6 +2666,12 @@ class Interface:
         """
         Join the room immediately
         """
+
+        if gajim.contacts.get_contact(account, room_jid):
+            dialogs.ErrorDialog(_('This is not a group chat'),
+                _('%s is not the name of a group chat.') % room_jid)
+            return
+
         if not nick:
             nick = gajim.nicks[account]
 
@@ -3158,7 +3164,7 @@ class Interface:
                 if not jid in gajim.gc_connected[account]:
                     # we are not already connected
                     minimize = bm['minimize'] in ('1', 'true')
-                    gajim.interface.join_gc_room(account, jid, bm['nick'],
+                    self.join_gc_room(account, jid, bm['nick'],
                     bm['password'], minimize = minimize)
                 elif jid in self.minimized_controls[account]:
                     # more or less a hack:
-- 
GitLab