Mercurial > libervia-backend
comparison src/plugins/plugin_misc_maildir.py @ 1955:633b5c21aefd
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.
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 24 May 2016 22:11:04 +0200 |
parents | 2daf7b4c6756 |
children | 1d3f73e065e1 |
comparison
equal
deleted
inserted
replaced
1943:ccfe45302a5c | 1955:633b5c21aefd |
---|---|
96 def profileDisconnected(self, profile): | 96 def profileDisconnected(self, profile): |
97 """Called on profile disconnection, free profile's resources""" | 97 """Called on profile disconnection, free profile's resources""" |
98 del self.__mailboxes[profile] | 98 del self.__mailboxes[profile] |
99 del self.data[profile] | 99 del self.data[profile] |
100 | 100 |
101 def messageReceivedTrigger(self, message, post_treat, profile): | 101 def messageReceivedTrigger(self, client, message, post_treat): |
102 """This trigger catch normal message and put the in the Maildir box. | 102 """This trigger catch normal message and put the in the Maildir box. |
103 If the message is not of "normal" type, do nothing | 103 If the message is not of "normal" type, do nothing |
104 @param message: message xmlstrem | 104 @param message: message xmlstrem |
105 @return: False if it's a normal message, True else""" | 105 @return: False if it's a normal message, True else""" |
106 for e in message.elements(): | 106 profile = client.profile |
107 if e.name == "body": | 107 for e in message.elements(C.NS_CLIENT, 'body'): |
108 mess_type = message['type'] if message.hasAttribute('type') else 'normal' | 108 mess_type = message.getAttribute('type', 'normal') |
109 if mess_type != 'normal': | 109 if mess_type != 'normal': |
110 return True | 110 return True |
111 self.accessMessageBox("INBOX", profile_key=profile).addMessage(message) | 111 self.accessMessageBox("INBOX", profile_key=profile).addMessage(message) |
112 return not self.host.memory.getParamA(NAME, CATEGORY, profile_key=profile) | 112 return not self.host.memory.getParamA(NAME, CATEGORY, profile_key=profile) |
113 return True | |
113 | 114 |
114 def accessMessageBox(self, boxname, observer=None, profile_key=C.PROF_KEY_NONE): | 115 def accessMessageBox(self, boxname, observer=None, profile_key=C.PROF_KEY_NONE): |
115 """Create and return a MailboxUser instance | 116 """Create and return a MailboxUser instance |
116 @param boxname: name of the box | 117 @param boxname: name of the box |
117 @param observer: method to call when a NewMessage arrive""" | 118 @param observer: method to call when a NewMessage arrive""" |