Commit 4feb9d4a authored by Philipp Hörist's avatar Philipp Hörist

Simplify AffiliationResult

parent deba7180
......@@ -300,18 +300,12 @@ class MUC:
iq = Iq(typ='get', to=jid, queryNS=NS_MUC_ADMIN)
item = iq.setQuery().setTag('item')
item.setAttr('affiliation', affiliation)
return iq, {'affiliation': affiliation}
return iq
@callback
def _affiliation_received(self, stanza, affiliation):
def _affiliation_received(self, stanza):
if not isResultNode(stanza):
log.info('Affiliation error: %s %s %s',
stanza.getFrom(),
stanza.getError(),
affiliation)
return AffiliationResult(jid=stanza.getFrom(),
affiliation=affiliation,
error=stanza.getError())
return raise_error(log.info, stanza)
room_jid = stanza.getFrom()
query = stanza.getTag('query', namespace=NS_MUC_ADMIN)
......@@ -333,12 +327,10 @@ class MUC:
if reason:
users_dict[jid]['reason'] = reason
log.info('%s affiliations received from %s: %s',
affiliation, room_jid, users_dict)
log.info('Affiliations received from %s: %s',
room_jid, users_dict)
return AffiliationResult(jid=room_jid,
affiliation=affiliation,
users=users_dict)
return AffiliationResult(jid=room_jid, users=users_dict)
@call_on_response('_default_response')
def destroy(self, room_jid, reason='', jid=''):
......
......@@ -51,6 +51,8 @@ MucUserData.__new__.__defaults__ = (None, None, None, None, None)
MucDestroyed = namedtuple('MucDestroyed', 'alternate reason password')
MucDestroyed.__new__.__defaults__ = (None, None, None)
AffiliationResult = namedtuple('AffiliationResult', 'jid users')
EntityCapsData = namedtuple('EntityCapsData', 'hash node ver')
EntityCapsData.__new__.__defaults__ = (None, None, None)
......@@ -376,13 +378,6 @@ class CommonResult(BaseResult, namedtuple('CommonResult', 'jid error')):
CommonResult.__new__.__defaults__ = (None,)
class AffiliationResult(BaseResult, namedtuple('AffiliationResult',
'jid affiliation users error')):
pass
AffiliationResult.__new__.__defaults__ = (None, None)
class MucConfigResult(BaseResult, namedtuple('MucConfigResult',
'jid form error')):
pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment