Fix regarding support ticket to support ticket system email chaining issue

This commit is contained in:
Anand Doshi 2012-01-05 13:54:29 +05:30
parent 5e57a39bb1
commit 9dfc9f617b

View File

@ -40,18 +40,32 @@ class SupportMailbox(POP3Mailbox):
else:
content, content_type = mail.html_content, 'text/html'
thread_id = mail.get_thread_id()
thread_list = mail.get_thread_id()
if webnotes.conn.exists('Support Ticket', thread_id):
from webnotes.model.code import get_obj
st = get_obj('Support Ticket', thread_id)
st.make_response_record(content, mail.mail['From'], content_type)
webnotes.conn.set(st.doc, 'status', 'Open')
update_feed(st.doc)
# extract attachments
self.save_attachments(st.doc, mail.attachments)
return
email_id = mail.mail['From']
if "<" in mail.mail['From']:
import re
re_result = re.findall('(?<=\<)(\S+)(?=\>)', mail.mail['From'])
if re_result and re_result[0]: email_id = res_result[0]
for thread_id in thread_list:
exists = webnotes.conn.sql("""\
SELECT name
FROM `tabSupport Ticket`
WHERE name=%s AND raised_by LIKE %s
""", (thread_id, "%" + email_id + "%"))
if exists and exists[0] and exists[0][0]:
from webnotes.model.code import get_obj
st = get_obj('Support Ticket', thread_id)
st.make_response_record(content, mail.mail['From'], content_type)
webnotes.conn.set(st.doc, 'status', 'Open')
update_feed(st.doc)
# extract attachments
self.save_attachments(st.doc, mail.attachments)
return
# new ticket
from webnotes.model.doc import Document