Adapt to AffiliationResult changes in nbxmpp

This commit is contained in:
Philipp Hörist 2019-02-11 21:05:20 +01:00
parent f8373012a2
commit 94160d830f
1 changed files with 14 additions and 12 deletions

View File

@ -15,6 +15,7 @@
import logging import logging
import nbxmpp import nbxmpp
from nbxmpp.util import is_error_result
from gi.repository import Gdk from gi.repository import Gdk
from gi.repository import Gtk from gi.repository import Gtk
@ -65,7 +66,8 @@ class GroupchatConfig(Gtk.ApplicationWindow):
con.get_module('MUC').get_affiliation( con.get_module('MUC').get_affiliation(
self.jid, self.jid,
affiliation, affiliation,
callback=self._on_affiliations_received) callback=self._on_affiliations_received,
user_data=affiliation)
if form is not None: if form is not None:
self._ui.stack.set_visible_child_name('config') self._ui.stack.set_visible_child_name('config')
@ -352,28 +354,28 @@ class GroupchatConfig(Gtk.ApplicationWindow):
con.get_module('MUC').set_affiliation(self.jid, diff_dict) con.get_module('MUC').set_affiliation(self.jid, diff_dict)
@ensure_not_destroyed @ensure_not_destroyed
def _on_affiliations_received(self, result): def _on_affiliations_received(self, result, affiliation):
if result.is_error: if is_error_result(result):
log.info('Error while requesting %s affiliations: %s', log.info('Error while requesting %s affiliations: %s',
result.affiliation, result.error) affiliation, result)
return return
if result.affiliation == 'outcast': if affiliation == 'outcast':
self._ui.stack.get_child_by_name('outcast').show() self._ui.stack.get_child_by_name('outcast').show()
for jid, attrs in result.users.items(): for jid, attrs in result.users.items():
affiliation_edit, jid_edit = self._allowed_to_edit(result.affiliation) affiliation_edit, jid_edit = self._allowed_to_edit(affiliation)
if result.affiliation == 'outcast': if affiliation == 'outcast':
reason = attrs.get('reason') reason = attrs.get('reason')
self._ui.outcast_store.append( self._ui.outcast_store.append(
[jid, [jid,
reason, reason,
None, None,
result.affiliation, affiliation,
None, None,
affiliation_edit, affiliation_edit,
jid_edit]) jid_edit])
self._affiliations[jid] = {'affiliation': result.affiliation, self._affiliations[jid] = {'affiliation': affiliation,
'reason': reason} 'reason': reason}
else: else:
nick = attrs.get('nick') nick = attrs.get('nick')
@ -382,11 +384,11 @@ class GroupchatConfig(Gtk.ApplicationWindow):
[jid, [jid,
nick, nick,
role, role,
result.affiliation, affiliation,
_(result.affiliation.capitalize()), _(affiliation.capitalize()),
affiliation_edit, affiliation_edit,
jid_edit]) jid_edit])
self._affiliations[jid] = {'affiliation': result.affiliation, self._affiliations[jid] = {'affiliation': affiliation,
'nick': nick} 'nick': nick}
if role is not None: if role is not None:
self._ui.role_column.set_visible(True) self._ui.role_column.set_visible(True)