core, quick_frontend, primitivus, wixi, bridge: fixed delayed message timestamp:
- new "extra" parameter in newMessage signal
This commit is contained in:
parent
fef2b1a620
commit
65103362a6
2 changed files with 39 additions and 28 deletions
|
|
@ -501,7 +501,7 @@ class SAT(service.Service):
|
|||
if mess_data["type"]!="groupchat":
|
||||
self.memory.addToHistory(current_jid, jid.JID(to), unicode(mess_data["message"]), unicode(mess_data["type"]), profile=profile) #we don't add groupchat message to history, as we get them back
|
||||
#and they will be added then
|
||||
self.bridge.newMessage(message['from'], unicode(mess_data["message"]), mess_type=mess_data["type"], to_jid=message['to'], profile=profile) #We send back the message, so all clients are aware of it
|
||||
self.bridge.newMessage(message['from'], unicode(mess_data["message"]), mess_type=mess_data["type"], to_jid=message['to'], extra={}, profile=profile) #We send back the message, so all clients are aware of it
|
||||
|
||||
|
||||
def setPresence(self, to="", show="", priority = 0, statuses={}, profile_key='@DEFAULT@'):
|
||||
|
|
|
|||
|
|
@ -21,9 +21,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
from twisted.internet import task, defer
|
||||
from twisted.words.protocols.jabber import jid, xmlstream
|
||||
from wokkel import client, disco, xmppim, generic, compat
|
||||
from wokkel import client, disco, xmppim, generic, compat, delay
|
||||
from logging import debug, info, error
|
||||
from sat.core import exceptions
|
||||
from calendar import timegm
|
||||
|
||||
|
||||
class SatXMPPClient(client.XMPPClient):
|
||||
|
|
@ -104,17 +105,25 @@ class SatMessageProtocol(xmppim.MessageProtocol):
|
|||
self.host = host
|
||||
|
||||
def onMessage(self, message):
|
||||
debug (_(u"got message from: %s"), message["from"])
|
||||
if not self.host.trigger.point("MessageReceived",message, profile=self.parent.profile):
|
||||
return
|
||||
for e in message.elements():
|
||||
if e.name == "body":
|
||||
mess_type = message['type'] if message.hasAttribute('type') else 'normal'
|
||||
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"]), mess_body, mess_type, profile=self.parent.profile)
|
||||
break
|
||||
debug (_(u"got message from: %s"), message["from"])
|
||||
if not self.host.trigger.point("MessageReceived",message, profile=self.parent.profile):
|
||||
return
|
||||
for e in message.elements():
|
||||
if e.name == "body":
|
||||
mess_type = message['type'] if message.hasAttribute('type') else 'normal'
|
||||
mess_body = e.children[0] if e.children else ""
|
||||
try:
|
||||
_delay = delay.Delay.fromElement(filter(lambda elm: elm.name == 'delay', message.elements())[0])
|
||||
timestamp = timegm(_delay.stamp.utctimetuple())
|
||||
extra = {"archive": str(timestamp)}
|
||||
if mess_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
|
||||
self.host.memory.addToHistory(jid.JID(message["from"]), jid.JID(message["to"]), mess_body, mess_type, timestamp, profile=self.parent.profile)
|
||||
except IndexError:
|
||||
extra = {}
|
||||
self.host.memory.addToHistory(jid.JID(message["from"]), jid.JID(message["to"]), mess_body, mess_type, profile=self.parent.profile)
|
||||
self.host.bridge.newMessage(message["from"], mess_body, mess_type, message['to'], extra, profile=self.parent.profile)
|
||||
break
|
||||
|
||||
class SatRosterProtocol(xmppim.RosterClientProtocol):
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue