]> khamidou — GitHub mirrors - kite.git/commitdiff
added unread messages count to backend
authorkarim hamidou <khamidou@gmail.com>
Wed, 4 Jun 2014 15:09:50 +0000 (17:09 +0200)
committerkarim hamidou <khamidou@gmail.com>
Wed, 4 Jun 2014 15:09:50 +0000 (17:09 +0200)
src/back/kite/filterdaemon.py
src/back/kite/threads.py

index 1b49d628aef670ecb0628a1fbc9ed4b774d7fc02..b756b656aabf5662df8c31bf9be183b2a6751bd3 100755 (executable)
@@ -94,7 +94,6 @@ def process_new_email(path, threads_index):
             msg_id = os.path.basename(path)
             thread["messages"].append(msg_id)
             thread["date"] = datetime.datetime.utcnow()
-            thread["unread"] = True
 
             if from_field["address"] != thread["creator"]["address"]:
                 thread["lastreplyfrom"] = from_field
@@ -118,10 +117,11 @@ class ProcessorThread(threading.Thread):
 
                         if username not in self.threads_index:
                             print "Setting threads_index for user : %s" % username
-                            self.threads_index[username] = {"threads_index": [], "dirty": True}
+                            self.threads_index[username] = {"threads_index": [], "dirty": True, "unread_count": 0}
                         
                         process_new_email(event["path"], self.threads_index[username]["threads_index"])
                         self.threads_index[username]["dirty"] = True
+                        self.threads_index[username]["unread_count"] += 1
                     except IOError as e:
                         # This may be a Postfix/Dovecot temporary file. Ignore it.
                         print "caught ioerror %s" % e.strerror
index a5e09ada1996caf99838950cb6df87dc415482d1..f6a4c09dbf95d36c3f3b7c1da6298b361f831bdb 100644 (file)
@@ -10,4 +10,4 @@ def generate_random_id():
     return base64.b32encode(os.urandom(32))
     
 def create_thread_structure():
-    return {"date": datetime.datetime.utcnow(), "messages": [], "subject": "", "id": generate_random_id()}
+    return {"date": datetime.datetime.utcnow(), "messages": [], "subject": "", "id": generate_random_id(), "unread": True}