Populate the to attribute for message and presence stanzas if the server leaves it blank.
This commit is contained in:
parent
2eeaf4d80c
commit
8b47159788
@ -666,19 +666,17 @@ class BaseXMPP(XMLStream):
|
|||||||
|
|
||||||
def _handle_message(self, msg):
|
def _handle_message(self, msg):
|
||||||
"""Process incoming message stanzas."""
|
"""Process incoming message stanzas."""
|
||||||
|
if not self.is_component and not msg['to'].bare:
|
||||||
|
msg['to'] = self.boundjid
|
||||||
self.event('message', msg)
|
self.event('message', msg)
|
||||||
|
|
||||||
def _handle_available(self, presence):
|
def _handle_available(self, presence):
|
||||||
pto = presence['to'].bare
|
pto = presence['to'].bare
|
||||||
if not pto:
|
|
||||||
pto = self.boundjid.bare
|
|
||||||
pfrom = presence['from'].bare
|
pfrom = presence['from'].bare
|
||||||
self.roster[pto][pfrom].handle_available(presence)
|
self.roster[pto][pfrom].handle_available(presence)
|
||||||
|
|
||||||
def _handle_unavailable(self, presence):
|
def _handle_unavailable(self, presence):
|
||||||
pto = presence['to'].bare
|
pto = presence['to'].bare
|
||||||
if not pto:
|
|
||||||
pto = self.boundjid.bare
|
|
||||||
pfrom = presence['from'].bare
|
pfrom = presence['from'].bare
|
||||||
self.roster[pto][pfrom].handle_unavailable(presence)
|
self.roster[pto][pfrom].handle_unavailable(presence)
|
||||||
|
|
||||||
@ -735,6 +733,9 @@ class BaseXMPP(XMLStream):
|
|||||||
|
|
||||||
Update the roster with presence information.
|
Update the roster with presence information.
|
||||||
"""
|
"""
|
||||||
|
if not self.is_component and not presence['to'].bare:
|
||||||
|
presence['to'] = self.boundjid
|
||||||
|
|
||||||
self.event("presence_%s" % presence['type'], presence)
|
self.event("presence_%s" % presence['type'], presence)
|
||||||
|
|
||||||
# Check for changes in subscription state.
|
# Check for changes in subscription state.
|
||||||
|
Loading…
Reference in New Issue
Block a user