Propagate presences further

Other modules like avatars and entity caps come after the base presence handlers
This commit is contained in:
Philipp Hörist 2019-01-11 20:45:11 +01:00
parent 4f2f2195aa
commit b22f1baca5
4 changed files with 18 additions and 15 deletions

View File

@ -38,7 +38,7 @@ class Caps:
StanzaHandler(name='presence', StanzaHandler(name='presence',
callback=self._entity_caps, callback=self._entity_caps,
ns=nbxmpp.NS_CAPS, ns=nbxmpp.NS_CAPS,
priority=45), priority=51),
] ]
self._capscache = caps_cache.capscache self._capscache = caps_cache.capscache

View File

@ -163,7 +163,7 @@ class MUC:
def _on_muc_presence(self, _con, _stanza, properties): def _on_muc_presence(self, _con, _stanza, properties):
if properties.type == PresenceType.ERROR: if properties.type == PresenceType.ERROR:
self._raise_muc_event('muc-presence-error', properties) self._raise_muc_event('muc-presence-error', properties)
raise nbxmpp.NodeProcessed return
def _on_muc_user_presence(self, _con, _stanza, properties): def _on_muc_user_presence(self, _con, _stanza, properties):
if properties.type == PresenceType.ERROR: if properties.type == PresenceType.ERROR:
@ -175,7 +175,7 @@ class MUC:
contact.presence = PresenceType.UNAVAILABLE contact.presence = PresenceType.UNAVAILABLE
log.info('MUC destroyed: %s', properties.jid.getBare()) log.info('MUC destroyed: %s', properties.jid.getBare())
self._raise_muc_event('muc-destroyed', properties) self._raise_muc_event('muc-destroyed', properties)
raise nbxmpp.NodeProcessed return
contact = app.contacts.get_gc_contact(self._account, contact = app.contacts.get_gc_contact(self._account,
properties.jid.getBare(), properties.jid.getBare(),
@ -189,7 +189,7 @@ class MUC:
properties.jid, properties.jid,
properties.muc_user.nick) properties.muc_user.nick)
self._raise_muc_event('muc-nickname-changed', properties) self._raise_muc_event('muc-nickname-changed', properties)
raise nbxmpp.NodeProcessed return
if contact is None and properties.type.is_available: if contact is None and properties.type.is_available:
self._add_new_muc_contact(properties) self._add_new_muc_contact(properties)
@ -199,16 +199,16 @@ class MUC:
else: else:
log.info('User joined: %s', properties.jid) log.info('User joined: %s', properties.jid)
self._raise_muc_event('muc-user-joined', properties) self._raise_muc_event('muc-user-joined', properties)
raise nbxmpp.NodeProcessed return
if properties.is_muc_self_presence and properties.is_kicked: if properties.is_muc_self_presence and properties.is_kicked:
self._raise_muc_event('muc-self-kicked', properties) self._raise_muc_event('muc-self-kicked', properties)
raise nbxmpp.NodeProcessed return
if properties.is_muc_self_presence and properties.type.is_unavailable: if properties.is_muc_self_presence and properties.type.is_unavailable:
# Its not a kick, so this is the reflection of our own # Its not a kick, so this is the reflection of our own
# unavailable presence, because we left the MUC # unavailable presence, because we left the MUC
raise nbxmpp.NodeProcessed return
if properties.type.is_unavailable: if properties.type.is_unavailable:
for _event in app.events.get_events(self._account, for _event in app.events.get_events(self._account,
@ -237,7 +237,7 @@ class MUC:
app.contacts.remove_gc_contact(self._account, contact) app.contacts.remove_gc_contact(self._account, contact)
log.info('User %s left', properties.jid) log.info('User %s left', properties.jid)
self._raise_muc_event('muc-user-left', properties) self._raise_muc_event('muc-user-left', properties)
raise nbxmpp.NodeProcessed return
if contact.affiliation != properties.affiliation: if contact.affiliation != properties.affiliation:
contact.affiliation = properties.affiliation contact.affiliation = properties.affiliation
@ -263,8 +263,6 @@ class MUC:
properties.show) properties.show)
self._raise_muc_event('muc-user-status-show-changed', properties) self._raise_muc_event('muc-user-status-show-changed', properties)
raise nbxmpp.NodeProcessed
def _raise_muc_event(self, event_name, properties): def _raise_muc_event(self, event_name, properties):
app.nec.push_incoming_event( app.nec.push_incoming_event(
NetworkEvent(event_name, NetworkEvent(event_name,

View File

@ -65,25 +65,29 @@ class Presence:
self.jids_for_auto_auth = [] self.jids_for_auto_auth = []
def _presence_received(self, _con, stanza, properties): def _presence_received(self, _con, stanza, properties):
if properties.from_muc:
# Already handled in MUC module
return
log.info('Received from %s', properties.jid) log.info('Received from %s', properties.jid)
if properties.type == PresenceType.ERROR: if properties.type == PresenceType.ERROR:
log.info('Error: %s %s', properties.jid, properties.error) log.info('Error: %s %s', properties.jid, properties.error)
raise nbxmpp.NodeProcessed return
if self._account == 'Local': if self._account == 'Local':
app.nec.push_incoming_event( app.nec.push_incoming_event(
NetworkEvent('raw-pres-received', NetworkEvent('raw-pres-received',
conn=self._con, conn=self._con,
stanza=stanza)) stanza=stanza))
raise nbxmpp.NodeProcessed return
if properties.is_self_presence: if properties.is_self_presence:
app.nec.push_incoming_event( app.nec.push_incoming_event(
NetworkEvent('our-show', NetworkEvent('our-show',
conn=self._con, conn=self._con,
show=properties.show.value)) show=properties.show.value))
raise nbxmpp.NodeProcessed return
contacts = app.contacts.get_jid_list(self._account) contacts = app.contacts.get_jid_list(self._account)
if properties.jid.getBare() not in contacts and not properties.is_self_bare: if properties.jid.getBare() not in contacts and not properties.is_self_bare:
@ -133,8 +137,6 @@ class Presence:
app.nec.push_incoming_event(event_) app.nec.push_incoming_event(event_)
raise nbxmpp.NodeProcessed
def _update_contact(self, event, properties): def _update_contact(self, event, properties):
# Note: A similar method also exists in connection_zeroconf # Note: A similar method also exists in connection_zeroconf
jid = properties.jid.getBare() jid = properties.jid.getBare()

View File

@ -56,6 +56,9 @@ class VCardAvatars:
app.config.set_per('accounts', self._account, 'avatar_sha', '') app.config.set_per('accounts', self._account, 'avatar_sha', '')
def _presence_received(self, _con, _stanza, properties): def _presence_received(self, _con, _stanza, properties):
if not properties.type.is_available:
return
if properties.avatar_state in (AvatarState.IGNORE, if properties.avatar_state in (AvatarState.IGNORE,
AvatarState.NOT_READY): AvatarState.NOT_READY):
return return