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
|
|
@ -248,7 +248,7 @@ class QuickApp(object):
|
|||
self.registerSignal("disconnected")
|
||||
self.registerSignal("actionNew")
|
||||
self.registerSignal("newContact")
|
||||
self.registerSignal("newMessage")
|
||||
self.registerSignal("messageNew")
|
||||
self.registerSignal("newAlert")
|
||||
self.registerSignal("presenceUpdate")
|
||||
self.registerSignal("subscribe")
|
||||
|
|
@ -482,10 +482,10 @@ class QuickApp(object):
|
|||
groups = list(groups)
|
||||
self.contact_lists[profile].setContact(entity, groups, attributes, in_roster=True)
|
||||
|
||||
def newMessageHandler(self, from_jid_s, msg, type_, to_jid_s, extra, profile):
|
||||
def messageNewHandler(self, uid, timestamp, from_jid_s, to_jid_s, msg, subject, type_, extra, profile):
|
||||
from_jid = jid.JID(from_jid_s)
|
||||
to_jid = jid.JID(to_jid_s)
|
||||
if not self.trigger.point("newMessageTrigger", from_jid, msg, type_, to_jid, extra, profile=profile):
|
||||
if not self.trigger.point("messageNewTrigger", uid, timestamp, from_jid, to_jid, msg, subject, type_, extra, profile=profile):
|
||||
return
|
||||
|
||||
from_me = from_jid.bare == self.profiles[profile].whoami.bare
|
||||
|
|
@ -505,7 +505,8 @@ class QuickApp(object):
|
|||
contact_list.setContact(from_jid)
|
||||
|
||||
# we display the message in the widget
|
||||
chat_widget.newMessage(from_jid, target, msg, type_, extra, profile)
|
||||
|
||||
chat_widget.messageNew(uid, timestamp, from_jid, target, msg, subject, type_, extra, profile)
|
||||
|
||||
# ContactList alert
|
||||
if not from_me:
|
||||
|
|
@ -520,16 +521,20 @@ class QuickApp(object):
|
|||
else:
|
||||
contact_list.addAlert(from_jid.bare if type_ == C.MESS_TYPE_GROUPCHAT else from_jid)
|
||||
|
||||
def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, callback=None, errback=None, profile_key=C.PROF_KEY_NONE):
|
||||
def messageSend(self, to_jid, message, subject=None, mess_type="auto", extra=None, callback=None, errback=None, profile_key=C.PROF_KEY_NONE):
|
||||
if subject is None:
|
||||
subject = {}
|
||||
if extra is None:
|
||||
extra = {}
|
||||
if callback is None:
|
||||
callback = lambda dummy=None: None # FIXME: optional argument is here because pyjamas doesn't support callback without arg with json proxy
|
||||
if errback is None:
|
||||
errback = lambda failure: self.showDialog(failure.fullname, failure.message, "error")
|
||||
|
||||
if not self.trigger.point("sendMessageTrigger", to_jid, message, subject, mess_type, extra, callback, errback, profile_key=profile_key):
|
||||
if not self.trigger.point("messageSendTrigger", to_jid, message, subject, mess_type, extra, callback, errback, profile_key=profile_key):
|
||||
return
|
||||
|
||||
self.bridge.sendMessage(unicode(to_jid), message, subject, mess_type, extra, profile_key, callback=callback, errback=errback)
|
||||
self.bridge.messageSend(unicode(to_jid), message, subject, mess_type, extra, profile_key, callback=callback, errback=errback)
|
||||
|
||||
def newAlertHandler(self, msg, title, alert_type, profile):
|
||||
assert alert_type in ['INFO', 'ERROR']
|
||||
|
|
|
|||
Loading…
Reference in a new issue