markup: remove email submission endpoint

This commit is contained in:
2020-03-11 15:42:45 -07:00
parent 7a8bbf85af
commit 75aab03c2e
3 changed files with 0 additions and 98 deletions

View File

@ -47,50 +47,6 @@ def on_fail_handler(self, exc, task_id, args, kwargs, einfo):
# raise KeyError()
@shared_task(on_failure=on_fail_handler)
def process_message(path):
parser = FeedParser()
with open(path) as f:
for line in f:
parser.feed(line)
msg = parser.close()
frm = str(make_header(decode_header(msg['From'])))
subject = str(make_header(decode_header(msg['Subject'])))
found_pdf = False
for attach in msg.walk():
if attach.get_content_type() == 'application/pdf':
process_attachment(frm, subject, attach)
found_pdf = True
if not found_pdf:
reply_missing(frm, subject)
def process_attachment(from_address, subject, attachment):
# write out pdf
pdf_name = attachment.get_filename()
pdf_name = str(make_header(decode_header(pdf_name)))
# if pdf name is in UUID format, use email subject
if re.match(r'[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\.pdf', pdf_name):
pdf_name = f'{subject}.pdf'
print(f'Using pdf name: {pdf_name}')
pdf_base = Path(pdf_name).stem
workdir = os.path.join(WORKDIR, clean_path(from_address), pdf_base)
ensure_dir(workdir)
pdf_path = os.path.join(workdir, pdf_name)
print(f'saving pdf to {pdf_path}')
with open(pdf_path, 'wb') as att:
att.write(attachment.get_payload(decode=True))
set_file_perms(pdf_path)
process_pdf(pdf_path, from_address, subject, workdir)
@shared_task(on_failure=on_fail_handler)
def process_markup_pdf(pdf_path, username):
if not Path(pdf_path).is_file():