markup: use email subject as pdf name if default is uuid
This commit is contained in:
@ -3,6 +3,7 @@ from celery import task, shared_task
|
||||
from celery.utils.log import get_task_logger
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import datetime
|
||||
import fileinput
|
||||
@ -66,6 +67,13 @@ 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)
|
||||
|
||||
Reference in New Issue
Block a user