]> khamidou — GitHub mirrors - kite.git/commitdiff
basic thread rendering
authorkarim hamidou <khamidou@gmail.com>
Sun, 15 Dec 2013 09:49:36 +0000 (10:49 +0100)
committerkarim hamidou <khamidou@gmail.com>
Sun, 15 Dec 2013 09:49:36 +0000 (10:49 +0100)
src/back/kite/filterdaemon.py
src/back/kite/server.py

index 748b2416431b0a6cbdc6875e0e610c1acea13c4d..e54daab3db07ad0d741b1c1220fd30cc9947c273 100755 (executable)
@@ -84,19 +84,21 @@ def process_new_email(path, threads_index):
         if subject != None:
             subject = headers.cleanup_subject(subject)
             thread = None
-            for thr in threads_index.data:
+            for index, thr in enumerate(threads_index.data):
                 if thr["subject"] == subject:
-                    thread = thr
+                    thread = threads_index.data.pop(index)
                     break
 
             if not thread:
                 # create a new thread
                 thread = threads.create_thread_structure()
                 thread["subject"] = subject
-                threads_index.data.append(thread)
 
-            thread["messages"].append(path)
+            msg_id = os.path.basename(path)
+            thread["messages"].append(msg_id)
             thread["date"] = datetime.datetime.utcnow()
+            threads_index.data.insert(0, thread)
+
 
 
 class ProcessorThread(threading.Thread):
index 506cefe1b33da9b3e7554429e0abd3791e202e02..cbf3b97f59ce772b76ec8b10e95bd6dda9ab38b9 100755 (executable)
@@ -2,6 +2,7 @@
 import bottle
 import json
 import jsonfile
+import sys
 from jsonfile import JsonFile
 from bottle import route, template, response, abort
 from maildir import *
@@ -25,15 +26,15 @@ def index(user, id):
                 if thr["id"] == id:
                     thread = thr
 
+            sys.stderr.write("thre % s" % json.dumps(thread, cls=jsonfile.DatetimeEncoder))
             if thread == None:
                 abort(404, "Thread not found.")
 
             response.content_type = "application/json"
 
             ret_json = []
-            mdir = read_mail("/home/kite/Maildir")
+            mdir = read_mail(sys.argv[1])
             for mail_id in thread["messages"]:
-                print "BOOYA %s\n!!" % mail_id
                 ret_json.append(get_email(mdir, mail_id)) 
 
             return json.dumps(ret_json)