plugin XEP-0203, core (xmpp): leave the management of delay element to XEP-0203 (fix bug 59):

- this patch reveals a bug in primitivus Chat.printMessage relative to MUC history (the test to discard duplicates is wrong)
This commit is contained in:
souliane 2015-12-11 11:25:29 +01:00
commit ab7ae07a83

View file

@ -26,7 +26,6 @@ from wokkel import client, disco, xmppim, generic, delay, iwokkel
from sat.core.log import getLogger
log = getLogger(__name__)
from sat.core import exceptions
from calendar import timegm
from zope.interface import implements
from twisted.words.protocols.jabber.xmlstream import XMPPHandler
@ -160,17 +159,15 @@ class SatMessageProtocol(xmppim.MessageProtocol):
return data
def addToHistory(data):
# set message body to empty string by default, and later
# also forward message without body (chat state notification...)
try:
_delay = delay.Delay.fromElement(filter(lambda elm: elm.name == 'delay', message.elements())[0])
timestamp = timegm(_delay.stamp.utctimetuple())
data['extra']['archive'] = str(timestamp)
timestamp = data['extra']['timestamp'] # timestamp added by XEP-0203
except KeyError:
self.host.memory.addToHistory(jid.JID(data['from']), jid.JID(data['to']), data['body'], data['type'], data['extra'], profile=self.parent.profile)
else:
if data['type'] != 'groupchat': # XXX: we don't save delayed messages in history for groupchats
#TODO: add delayed messages to history if they aren't already in it
data['extra']['archive'] = timestamp # FIXME: this "archive" is actually never used
self.host.memory.addToHistory(jid.JID(data['from']), jid.JID(data['to']), data['body'], data['type'], data['extra'], timestamp, profile=self.parent.profile)
except IndexError:
self.host.memory.addToHistory(jid.JID(data['from']), jid.JID(data['to']), data['body'], data['type'], data['extra'], profile=self.parent.profile)
return data
def treatmentsEb(failure):