[Git][gajim/gajim][master] 2 commits: Dont fail on users leaving a group chat

Philipp Hörist gitlab at dev.gajim.org
Sat Jan 5 19:17:56 CET 2019


Philipp Hörist pushed to branch master at gajim / gajim


Commits:
633795b7 by Philipp Hörist at 2019-01-05T18:17:34Z
Dont fail on users leaving a group chat

Fixes #9527

- - - - -
19c45510 by Philipp Hörist at 2019-01-05T18:17:34Z
MUC: Fix printing status/show

- rename config values to something more appropriate

- - - - -


4 changed files:

- gajim/common/config.py
- gajim/common/modules/muc.py
- gajim/groupchat_control.py
- gajim/gtk/preferences.py


Changes:

=====================================
gajim/common/config.py
=====================================
@@ -235,8 +235,8 @@ class Config:
         'show_location_in_roster': [opt_bool, True, '', True],
         'avatar_position_in_roster': [opt_str, 'right', _('Define the position of the avatar in roster. Can be left or right'), True],
         'print_status_in_chats': [opt_bool, False, _('If False, Gajim will no longer print status line in chats when a contact changes their status and/or their status message.')],
-        'print_join_leave_in_mucs': [opt_bool, False, _('Default Setting: Show a status message for every join or leave in a group chat')],
-        'print_status_in_mucs': [opt_bool, False, _('Default Setting: Show a status message for all status (away, dnd, etc.) changes of users in a group chat')],
+        'print_join_left_default': [opt_bool, False, _('Default Setting: Show a status message for every join or leave in a group chat')],
+        'print_status_muc_default': [opt_bool, False, _('Default Setting: Show a status message for all status (away, dnd, etc.) changes of users in a group chat')],
         'log_contact_status_changes': [opt_bool, False],
         'log_xhtml_messages': [opt_bool, False, _('Log XHTML messages instead of plain text messages.')],
         'restored_messages_small': [opt_bool, True, _('If true, restored messages will use a smaller font than the default one.')],


=====================================
gajim/common/modules/muc.py
=====================================
@@ -226,10 +226,16 @@ class MUC:
                 # handled by the opened ChatControl
                 break
 
-            # We remove the contact from the MUC, but there could be
-            # a PrivateChatControl open, so we update the contacts presence
-            contact.presence = properties.type
-            app.contacts.remove_gc_contact(self._account, contact)
+            if contact is None:
+                # If contact is None, its probably that a user left from a not
+                # insync MUC, can happen on older servers
+                log.warning('Unknown contact left groupchat: %s',
+                            properties.jid)
+            else:
+                # We remove the contact from the MUC, but there could be
+                # a PrivateChatControl open, so we update the contacts presence
+                contact.presence = properties.type
+                app.contacts.remove_gc_contact(self._account, contact)
             log.info('User %s left', properties.jid)
             self._raise_muc_event('muc-user-left', properties)
             raise nbxmpp.NodeProcessed


=====================================
gajim/groupchat_control.py
=====================================
@@ -397,7 +397,7 @@ class GroupchatControl(ChatControlBase):
         act.connect('change-state', self._on_notify_on_all_messages)
         self.parent_win.window.add_action(act)
 
-        status_default = app.config.get('print_status_in_mucs')
+        status_default = app.config.get('print_status_muc_default')
         value = app.config.get_per('rooms', self.contact.jid,
                                    'print_status', status_default)
 
@@ -407,7 +407,7 @@ class GroupchatControl(ChatControlBase):
         act.connect('change-state', self._on_print_status)
         self.parent_win.window.add_action(act)
 
-        join_default = app.config.get('print_join_leave_in_mucs')
+        join_default = app.config.get('print_join_left_default')
         value = app.config.get_per('rooms', self.contact.jid,
                                    'print_join_left', join_default)
 
@@ -2008,8 +2008,9 @@ class GroupchatControl(ChatControlBase):
         #Group Chat: We have been removed from the room
         message = _('{nick} has been removed from the room{by}{reason}')
 
+        join_default = app.config.get('print_join_left_default')
         print_join_left = app.config.get_per(
-            'rooms', self.room_jid, 'print_join_left')
+            'rooms', self.room_jid, 'print_join_left', join_default)
 
         if StatusCode.REMOVED_ERROR in status_codes:
             # Handle 333 before 307, some MUCs add both
@@ -2060,8 +2061,9 @@ class GroupchatControl(ChatControlBase):
             return
 
         nick = event.properties.muc_nickname
+        join_default = app.config.get('print_join_left_default')
         print_join_left = app.config.get_per(
-            'rooms', self.room_jid, 'print_join_left')
+            'rooms', self.room_jid, 'print_join_left', join_default)
 
         self.add_contact_to_roster(nick)
 


=====================================
gajim/gtk/preferences.py
=====================================
@@ -161,10 +161,10 @@ class Preferences(Gtk.ApplicationWindow):
         self._ui.sync_threshold_combobox.set_id_column(0)
         self._ui.sync_threshold_combobox.set_active_id(str(public_threshold))
 
-        st = app.config.get('print_join_leave_in_mucs')
+        st = app.config.get('print_join_left_default')
         self._ui.join_leave_checkbutton.set_active(st)
 
-        st = app.config.get('print_status_in_mucs')
+        st = app.config.get('print_status_muc_default')
         self._ui.status_change_checkbutton.set_active(st)
 
         # Displayed chat state notifications
@@ -620,10 +620,10 @@ class Preferences(Gtk.ApplicationWindow):
         app.config.set('public_room_sync_threshold', int(active))
 
     def _on_join_leave_toggled(self, widget):
-        self.on_checkbutton_toggled(widget, 'print_join_leave_in_mucs')
+        self.on_checkbutton_toggled(widget, 'print_join_left_default')
 
     def _on_status_change_toggled(self, widget):
-        self.on_checkbutton_toggled(widget, 'print_status_in_mucs')
+        self.on_checkbutton_toggled(widget, 'print_status_muc_default')
 
     def on_show_chatstate_in_tabs_toggled(self, widget):
         self.on_checkbutton_toggled(widget, 'show_chatstate_in_tabs')



View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/a91f5f2c4914b597c9833894c8a31c6ba054ed39...19c45510a03bd771238038f61657f460df7c28cc

-- 
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/a91f5f2c4914b597c9833894c8a31c6ba054ed39...19c45510a03bd771238038f61657f460df7c28cc
You're receiving this email because of your account on dev.gajim.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gajim.org/pipermail/commits/attachments/20190105/3e9a621f/attachment-0001.html>


More information about the Commits mailing list