backend, frontend: messages refactoring (huge commit, not finished):
/!\ database schema has been modified, do a backup before updating
message have been refactored, here are the main changes:
- languages are now handled
- all messages have an uid (internal to SàT)
- message updating is anticipated
- subject is now first class
- new naming scheme is used newMessage => messageNew, getHistory => historyGet, sendMessage => messageSend
- minimal compatibility refactoring in quick_frontend/Primitivus, better refactoring should follow
- threads handling
- delayed messages are saved into history
- info messages may also be saved in history (e.g. to keep track of people joining/leaving a room)
- duplicate messages should be avoided
- historyGet return messages in right order, no need to sort again
- plugins have been updated to follow new features, some of them need to be reworked (e.g. OTR)
- XEP-0203 (Delayed Delivery) is now fully handled in core, the plugin just handle disco and creation of a delay element
- /!\ jp and Libervia are currently broken, as some features of Primitivus
It has been put in one huge commit to avoid breaking messaging between changes.
This is the main part of message refactoring, other commits will follow to take profit of the new features/behaviour.
This commit is contained in:
parent
eff7ec3ded
commit
f12803fa65
1 changed files with 784 additions and 453 deletions
|
|
@ -103,7 +103,7 @@ class XEP_0085(object):
|
|||
|
||||
# triggers from core
|
||||
host.trigger.add("MessageReceived", self.messageReceivedTrigger)
|
||||
host.trigger.add("sendMessage", self.sendMessageTrigger)
|
||||
host.trigger.add("messageSend", self.messageSendTrigger)
|
||||
host.trigger.add("paramUpdateTrigger", self.paramUpdateTrigger)
|
||||
|
||||
# args: to_s (jid as string), profile
|
||||
|
|
@ -156,11 +156,12 @@ class XEP_0085(object):
|
|||
return False
|
||||
return True
|
||||
|
||||
def messageReceivedTrigger(self, message, post_treat, profile):
|
||||
def messageReceivedTrigger(self, client, message, post_treat):
|
||||
"""
|
||||
Update the entity cache when we receive a message with body.
|
||||
Check for a chat state in the message and signal frontends.
|
||||
"""
|
||||
profile = client.profile
|
||||
if not self.host.memory.getParamA(PARAM_NAME, PARAM_KEY, profile_key=profile):
|
||||
return True
|
||||
|
||||
|
|
@ -197,11 +198,12 @@ class XEP_0085(object):
|
|||
break
|
||||
return True
|
||||
|
||||
def sendMessageTrigger(self, mess_data, pre_xml_treatments, post_xml_treatments, profile):
|
||||
def messageSendTrigger(self, client, mess_data, pre_xml_treatments, post_xml_treatments):
|
||||
"""
|
||||
Eventually add the chat state to the message and initiate
|
||||
the state machine when sending an "active" state.
|
||||
"""
|
||||
profile = client.profile
|
||||
def treatment(mess_data):
|
||||
message = mess_data['xml']
|
||||
to_jid = JID(message.getAttribute("to"))
|
||||
|
|
@ -362,12 +364,15 @@ class ChatStateMachine(object):
|
|||
# send a new message without body
|
||||
log.debug(u"sending state '{state}' to {jid}".format(state=state, jid=self.to_jid.full()))
|
||||
client = self.host.getClient(self.profile)
|
||||
mess_data = {'message': None,
|
||||
'type': self.mess_type,
|
||||
'from': client.jid,
|
||||
'to': self.to_jid,
|
||||
'subject': None
|
||||
}
|
||||
mess_data = {
|
||||
'from': client.jid,
|
||||
'to': self.to_jid,
|
||||
'uid': '',
|
||||
'message': {},
|
||||
'type': self.mess_type,
|
||||
'subject': {},
|
||||
'extra': {},
|
||||
}
|
||||
self.host.generateMessageXML(mess_data)
|
||||
mess_data['xml'].addElement(state, NS_CHAT_STATES)
|
||||
client.xmlstream.send(mess_data['xml'])
|
||||
|
|
|
|||
Loading…
Reference in a new issue