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:
Goffi 2016-05-24 22:11:04 +02:00
commit f12803fa65

View file

@ -72,11 +72,12 @@ class XEP_0033(object):
log.info(_("Extended Stanza Addressing plugin initialization"))
self.host = host
self.internal_data = {}
host.trigger.add("sendMessage", self.sendMessageTrigger, trigger.TriggerManager.MIN_PRIORITY)
host.trigger.add("messageSend", self.messageSendTrigger, trigger.TriggerManager.MIN_PRIORITY)
host.trigger.add("MessageReceived", self.messageReceivedTrigger)
def sendMessageTrigger(self, mess_data, pre_xml_treatments, post_xml_treatments, profile):
def messageSendTrigger(self, client, mess_data, pre_xml_treatments, post_xml_treatments):
"""Process the XEP-0033 related data to be sent"""
profile = client.profile
def treatment(mess_data):
if not 'address' in mess_data['extra']:
@ -117,7 +118,7 @@ class XEP_0033(object):
Ideas:
- fix Prosody plugin to check if target server support the feature
- redesign the database to save only one entry to the database
- change the newMessage signal to eventually pass more than one recipient
- change the messageNew signal to eventually pass more than one recipient
"""
def send(mess_data, skip_send=False):
client = self.host.profiles[profile]
@ -161,7 +162,7 @@ class XEP_0033(object):
d = defer.Deferred().addCallback(lambda dummy: self.internal_data.pop(timestamp))
defer.DeferredList(defer_list).chainDeferred(d)
def messageReceivedTrigger(self, message, post_treat, profile):
def messageReceivedTrigger(self, client, message, post_treat):
"""In order to save the addressing information in the history"""
def post_treat_addr(data, addresses):
data['extra']['addresses'] = ""
@ -174,9 +175,10 @@ class XEP_0033(object):
try:
addresses = message.elements(NS_ADDRESS, 'addresses').next()
post_treat.addCallback(post_treat_addr, addresses.children)
except StopIteration:
pass # no addresses
else:
post_treat.addCallback(post_treat_addr, addresses.children)
return True
def getHandler(self, profile):