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):
import bottle
import json
import jsonfile
+import sys
from jsonfile import JsonFile
from bottle import route, template, response, abort
from maildir import *
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)