changeset 429:37285f2d37c8

core: fixed empty body error on new message
author Goffi <goffi@goffi.org>
date Fri, 11 Nov 2011 19:49:21 +0100
parents a4a9efadabfc
children 7c7ec2347b56
files src/core/xmpp.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/core/xmpp.py	Fri Nov 11 19:49:00 2011 +0100
+++ b/src/core/xmpp.py	Fri Nov 11 19:49:21 2011 +0100
@@ -109,9 +109,10 @@
       for e in message.elements():
           if e.name == "body":
               mess_type = message['type'] if message.hasAttribute('type') else 'normal'
-              self.host.bridge.newMessage(message["from"], e.children[0], mess_type, message['to'], profile=self.parent.profile)
+              mess_body = e.children[0] if e.children else ""
+              self.host.bridge.newMessage(message["from"], mess_body, mess_type, message['to'], profile=self.parent.profile)
               if not u"delay" in [elem.name for elem in message.elements()]: #we don't save delayed messages in history
-                  self.host.memory.addToHistory(jid.JID(message["from"]), jid.JID(message["to"]), e.children[0], profile=self.parent.profile)
+                  self.host.memory.addToHistory(jid.JID(message["from"]), jid.JID(message["to"]), mess_body, profile=self.parent.profile)
               break
     
 class SatRosterProtocol(xmppim.RosterClientProtocol):