diff src/memory/memory.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 a2bc5089c2eb
line wrap: on
line diff
--- a/src/memory/memory.py	Mon Apr 18 18:35:19 2016 +0200
+++ b/src/memory/memory.py	Tue May 24 22:11:04 2016 +0200
@@ -510,14 +510,12 @@
 
     ## History ##
 
-    def addToHistory(self, from_jid, to_jid, message, type_='chat', extra=None, timestamp=None, profile=C.PROF_KEY_NONE):
-        assert profile != C.PROF_KEY_NONE
-        if extra is None:
-            extra = {}
-        return self.storage.addToHistory(from_jid, to_jid, message, type_, extra, timestamp, profile)
+    def addToHistory(self, client, data):
+        return self.storage.addToHistory(data, client.profile)
 
-    def getHistory(self, from_jid, to_jid, limit=C.HISTORY_LIMIT_NONE, between=True, search=None, profile=C.PROF_KEY_NONE):
+    def historyGet(self, from_jid, to_jid, limit=C.HISTORY_LIMIT_NONE, between=True, search=None, profile=C.PROF_KEY_NONE):
         """Retrieve messages in history
+
         @param from_jid (JID): source JID (full, or bare for catchall)
         @param to_jid (JID): dest JID (full, or bare for catchall)
         @param limit (int): maximum number of messages to get:
@@ -527,7 +525,7 @@
         @param between (bool): confound source and dest (ignore the direction)
         @param search (str): pattern to filter the history results
         @param profile (str): %(doc_profile)s
-        @return: list of tuple as in http://wiki.goffi.org/wiki/Bridge_API#getHistory
+        @return: list of message data as in [messageNew]
         """
         assert profile != C.PROF_KEY_NONE
         if limit == C.HISTORY_LIMIT_DEFAULT:
@@ -536,7 +534,7 @@
             limit = None
         if limit == 0:
             return defer.succeed([])
-        return self.storage.getHistory(jid.JID(from_jid), jid.JID(to_jid), limit, between, search, profile)
+        return self.storage.historyGet(jid.JID(from_jid), jid.JID(to_jid), limit, between, search, profile)
 
     ## Statuses ##