comparison src/core/xmpp.py @ 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 ae446194c20c
children 62145e50eae5
comparison
equal deleted inserted replaced
428:a4a9efadabfc 429:37285f2d37c8
107 if not self.host.trigger.point("MessageReceived",message, profile=self.parent.profile): 107 if not self.host.trigger.point("MessageReceived",message, profile=self.parent.profile):
108 return 108 return
109 for e in message.elements(): 109 for e in message.elements():
110 if e.name == "body": 110 if e.name == "body":
111 mess_type = message['type'] if message.hasAttribute('type') else 'normal' 111 mess_type = message['type'] if message.hasAttribute('type') else 'normal'
112 self.host.bridge.newMessage(message["from"], e.children[0], mess_type, message['to'], profile=self.parent.profile) 112 mess_body = e.children[0] if e.children else ""
113 self.host.bridge.newMessage(message["from"], mess_body, mess_type, message['to'], profile=self.parent.profile)
113 if not u"delay" in [elem.name for elem in message.elements()]: #we don't save delayed messages in history 114 if not u"delay" in [elem.name for elem in message.elements()]: #we don't save delayed messages in history
114 self.host.memory.addToHistory(jid.JID(message["from"]), jid.JID(message["to"]), e.children[0], profile=self.parent.profile) 115 self.host.memory.addToHistory(jid.JID(message["from"]), jid.JID(message["to"]), mess_body, profile=self.parent.profile)
115 break 116 break
116 117
117 class SatRosterProtocol(xmppim.RosterClientProtocol): 118 class SatRosterProtocol(xmppim.RosterClientProtocol):
118 119
119 def __init__(self, host): 120 def __init__(self, host):