From 8b4715978802b94088c4440a87b9c86849cfd9cb Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Thu, 26 Apr 2012 15:46:18 -0700 Subject: Populate the to attribute for message and presence stanzas if the server leaves it blank. --- sleekxmpp/basexmpp.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sleekxmpp') diff --git a/sleekxmpp/basexmpp.py b/sleekxmpp/basexmpp.py index 5fcfbf6d..1c835460 100644 --- a/sleekxmpp/basexmpp.py +++ b/sleekxmpp/basexmpp.py @@ -666,19 +666,17 @@ class BaseXMPP(XMLStream): def _handle_message(self, msg): """Process incoming message stanzas.""" + if not self.is_component and not msg['to'].bare: + msg['to'] = self.boundjid self.event('message', msg) def _handle_available(self, presence): pto = presence['to'].bare - if not pto: - pto = self.boundjid.bare pfrom = presence['from'].bare self.roster[pto][pfrom].handle_available(presence) def _handle_unavailable(self, presence): pto = presence['to'].bare - if not pto: - pto = self.boundjid.bare pfrom = presence['from'].bare self.roster[pto][pfrom].handle_unavailable(presence) @@ -735,6 +733,9 @@ class BaseXMPP(XMLStream): 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) # Check for changes in subscription state. -- cgit v1.2.3