Commit b22f1bac authored by Philipp Hörist's avatar Philipp Hörist

Propagate presences further

Other modules like avatars and entity caps come after the base presence handlers
parent 4f2f2195
Pipeline #2969 passed with stages
in 3 minutes and 40 seconds
......@@ -38,7 +38,7 @@ class Caps:
StanzaHandler(name='presence',
callback=self._entity_caps,
ns=nbxmpp.NS_CAPS,
priority=45),
priority=51),
]
self._capscache = caps_cache.capscache
......
......@@ -163,7 +163,7 @@ class MUC:
def _on_muc_presence(self, _con, _stanza, properties):
if properties.type == PresenceType.ERROR:
self._raise_muc_event('muc-presence-error', properties)
raise nbxmpp.NodeProcessed
return
def _on_muc_user_presence(self, _con, _stanza, properties):
if properties.type == PresenceType.ERROR:
......@@ -175,7 +175,7 @@ class MUC:
contact.presence = PresenceType.UNAVAILABLE
log.info('MUC destroyed: %s', properties.jid.getBare())
self._raise_muc_event('muc-destroyed', properties)
raise nbxmpp.NodeProcessed
return
contact = app.contacts.get_gc_contact(self._account,
properties.jid.getBare(),
......@@ -189,7 +189,7 @@ class MUC:
properties.jid,
properties.muc_user.nick)
self._raise_muc_event('muc-nickname-changed', properties)
raise nbxmpp.NodeProcessed
return
if contact is None and properties.type.is_available:
self._add_new_muc_contact(properties)
......@@ -199,16 +199,16 @@ class MUC:
else:
log.info('User joined: %s', properties.jid)
self._raise_muc_event('muc-user-joined', properties)
raise nbxmpp.NodeProcessed
return
if properties.is_muc_self_presence and properties.is_kicked:
self._raise_muc_event('muc-self-kicked', properties)
raise nbxmpp.NodeProcessed
return
if properties.is_muc_self_presence and properties.type.is_unavailable:
# Its not a kick, so this is the reflection of our own
# unavailable presence, because we left the MUC
raise nbxmpp.NodeProcessed
return
if properties.type.is_unavailable:
for _event in app.events.get_events(self._account,
......@@ -237,7 +237,7 @@ class MUC:
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
return
if contact.affiliation != properties.affiliation:
contact.affiliation = properties.affiliation
......@@ -263,8 +263,6 @@ class MUC:
properties.show)
self._raise_muc_event('muc-user-status-show-changed', properties)
raise nbxmpp.NodeProcessed
def _raise_muc_event(self, event_name, properties):
app.nec.push_incoming_event(
NetworkEvent(event_name,
......
......@@ -65,25 +65,29 @@ class Presence:
self.jids_for_auto_auth = []
def _presence_received(self, _con, stanza, properties):
if properties.from_muc:
# Already handled in MUC module
return
log.info('Received from %s', properties.jid)
if properties.type == PresenceType.ERROR:
log.info('Error: %s %s', properties.jid, properties.error)
raise nbxmpp.NodeProcessed
return
if self._account == 'Local':
app.nec.push_incoming_event(
NetworkEvent('raw-pres-received',
conn=self._con,
stanza=stanza))
raise nbxmpp.NodeProcessed
return
if properties.is_self_presence:
app.nec.push_incoming_event(
NetworkEvent('our-show',
conn=self._con,
show=properties.show.value))
raise nbxmpp.NodeProcessed
return
contacts = app.contacts.get_jid_list(self._account)
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_)
raise nbxmpp.NodeProcessed
def _update_contact(self, event, properties):
# Note: A similar method also exists in connection_zeroconf
jid = properties.jid.getBare()
......
......@@ -56,6 +56,9 @@ class VCardAvatars:
app.config.set_per('accounts', self._account, 'avatar_sha', '')
def _presence_received(self, _con, _stanza, properties):
if not properties.type.is_available:
return
if properties.avatar_state in (AvatarState.IGNORE,
AvatarState.NOT_READY):
return
......
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