From 689f8370b8c2391cbc33905ef26bdba3e857798c Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Fri, 24 Aug 2012 09:37:40 +0200
Subject: [PATCH] send decline to the same jid (bare or full) from which we
 received he invite

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

diff --git a/src/dialogs.py b/src/dialogs.py
index c99674b976..c761e37cc5 100644
--- a/src/dialogs.py
+++ b/src/dialogs.py
@@ -4463,14 +4463,16 @@ class PrivacyListsWindow:
                      PrivacyListWindow(self.account, name, 'EDIT')
 
 class InvitationReceivedDialog:
-    def __init__(self, account, room_jid, contact_jid, password=None,
-                             comment=None, is_continued=False):
+    def __init__(self, account, room_jid, contact_fjid, password=None,
+    comment=None, is_continued=False):
 
         self.room_jid = room_jid
         self.account = account
         self.password = password
         self.is_continued = is_continued
-        self.contact_jid = contact_jid
+        self.contact_fjid = contact_fjid
+
+        jid = gajim.get_jid_without_resource(contact_fjid)
 
         pritext = _('''You are invited to a groupchat''')
         #Don't translate $Contact
@@ -4478,8 +4480,8 @@ class InvitationReceivedDialog:
             sectext = _('$Contact has invited you to join a discussion')
         else:
             sectext = _('$Contact has invited you to group chat %(room_jid)s')\
-                            % {'room_jid': room_jid}
-        contact = gajim.contacts.get_first_contact_from_jid(account, contact_jid)
+                % {'room_jid': room_jid}
+        contact = gajim.contacts.get_first_contact_from_jid(account, jid)
         contact_text = contact and contact.name or contact_jid
         sectext = sectext.replace('$Contact', contact_text)
 
@@ -4501,7 +4503,7 @@ class InvitationReceivedDialog:
 
         def on_no(text):
             gajim.connections[account].decline_invitation(self.room_jid,
-                self.contact_jid, text)
+                self.contact_fjid, text)
 
         YesNoDialog(pritext, sectext, text_label=_('Reason:'),
             on_response_yes=on_yes, on_response_no=on_no)
diff --git a/src/gui_interface.py b/src/gui_interface.py
index 89c93b0408..a64cb82d95 100644
--- a/src/gui_interface.py
+++ b/src/gui_interface.py
@@ -628,18 +628,19 @@ class Interface:
         jid = gajim.get_jid_without_resource(obj.jid_from)
         account = obj.conn.name
         if helpers.allow_popup_window(account) or not self.systray_enabled:
-            dialogs.InvitationReceivedDialog(account, obj.room_jid, jid,
-                obj.password, obj.reason, is_continued=obj.is_continued)
+            dialogs.InvitationReceivedDialog(account, obj.room_jid,
+                obj.jid_from, obj.password, obj.reason,
+                is_continued=obj.is_continued)
             return
 
-        self.add_event(account, jid, 'gc-invitation', (obj.room_jid,
+        self.add_event(account, obj.jid_from, 'gc-invitation', (obj.room_jid,
             obj.reason, obj.password, obj.is_continued))
 
         if helpers.allow_showing_notification(account):
             path = gtkgui_helpers.get_icon_path('gajim-gc_invitation', 48)
             event_type = _('Groupchat Invitation')
-            notify.popup(event_type, jid, account, 'gc-invitation', path,
-                event_type, obj.room_jid)
+            notify.popup(event_type, obj.jid_from, account, 'gc-invitation',
+                path, event_type, obj.room_jid)
 
     def forget_gpg_passphrase(self, keyid):
         if keyid in self.gpg_passphrase:
-- 
GitLab