Allow attachments in support ticket
This commit is contained in:
parent
ac20eb2107
commit
20f0d305cb
@ -33,6 +33,7 @@ class SupportMailbox(POP3Mailbox):
|
|||||||
Updates message from support email as either new or reply
|
Updates message from support email as either new or reply
|
||||||
"""
|
"""
|
||||||
from home import update_feed
|
from home import update_feed
|
||||||
|
from webnotes.utils.file_manager import save_file, add_file_list
|
||||||
|
|
||||||
content, content_type = '[Blank Email]', 'text/plain'
|
content, content_type = '[Blank Email]', 'text/plain'
|
||||||
if mail.text_content:
|
if mail.text_content:
|
||||||
@ -49,6 +50,8 @@ class SupportMailbox(POP3Mailbox):
|
|||||||
st.make_response_record(content, mail.mail['From'], content_type)
|
st.make_response_record(content, mail.mail['From'], content_type)
|
||||||
webnotes.conn.set(st.doc, 'status', 'Open')
|
webnotes.conn.set(st.doc, 'status', 'Open')
|
||||||
update_feed(st.doc)
|
update_feed(st.doc)
|
||||||
|
# extract attachments
|
||||||
|
self.save_attachments(doc=st.doc, attachment_list=mail.attachments)
|
||||||
return
|
return
|
||||||
|
|
||||||
# new ticket
|
# new ticket
|
||||||
@ -61,6 +64,7 @@ class SupportMailbox(POP3Mailbox):
|
|||||||
d.status = 'Open'
|
d.status = 'Open'
|
||||||
try:
|
try:
|
||||||
d.save(1)
|
d.save(1)
|
||||||
|
|
||||||
# update feed
|
# update feed
|
||||||
update_feed(d)
|
update_feed(d)
|
||||||
|
|
||||||
@ -70,6 +74,31 @@ class SupportMailbox(POP3Mailbox):
|
|||||||
except:
|
except:
|
||||||
d.description = 'Unable to extract message'
|
d.description = 'Unable to extract message'
|
||||||
d.save(1)
|
d.save(1)
|
||||||
|
|
||||||
|
else:
|
||||||
|
# extract attachments
|
||||||
|
self.save_attachments(doc=d, attachment_list=mail.attachments)
|
||||||
|
|
||||||
|
|
||||||
|
def save_attachments(self, doc, attachment_list=[]):
|
||||||
|
"""
|
||||||
|
Saves attachments from email
|
||||||
|
|
||||||
|
attachment_list is a list of dict containing:
|
||||||
|
'filename', 'content', 'content-type'
|
||||||
|
"""
|
||||||
|
for attachment in attachment_list:
|
||||||
|
fid = save_file(
|
||||||
|
fname=attachment['filename'],
|
||||||
|
content=attachment['content'],
|
||||||
|
module='Support'
|
||||||
|
)
|
||||||
|
status = add_file_list('Support Ticket', doc.name, attachment['filename'], fid)
|
||||||
|
if not status:
|
||||||
|
doc.description = doc.description \
|
||||||
|
+ "\nCould not attach: " + str(attachment['filename'])
|
||||||
|
doc.save()
|
||||||
|
|
||||||
|
|
||||||
def send_auto_reply(self, d):
|
def send_auto_reply(self, d):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user