diff --git a/src-ui/src/app/components/common/edit-dialog/mail-rule-edit-dialog/mail-rule-edit-dialog.component.ts b/src-ui/src/app/components/common/edit-dialog/mail-rule-edit-dialog/mail-rule-edit-dialog.component.ts index 624a4f676..3e9e7b1cc 100644 --- a/src-ui/src/app/components/common/edit-dialog/mail-rule-edit-dialog/mail-rule-edit-dialog.component.ts +++ b/src-ui/src/app/components/common/edit-dialog/mail-rule-edit-dialog/mail-rule-edit-dialog.component.ts @@ -61,19 +61,19 @@ const CONSUMPTION_SCOPE_OPTIONS = [ const PDF_LAYOUT_OPTIONS = [ { - id: MailRulePdfLayout.Text_Html, + id: MailRulePdfLayout.TextHtml, name: $localize`Text, then HTML`, }, { - id: MailRulePdfLayout.Html_Text, + id: MailRulePdfLayout.HtmlText, name: $localize`HTML, then text`, }, { - id: MailRulePdfLayout.Html_only, + id: MailRulePdfLayout.HtmlOnly, name: $localize`HTML only`, }, { - id: MailRulePdfLayout.Text_only, + id: MailRulePdfLayout.TextOnly, name: $localize`Text only`, }, ] @@ -204,7 +204,7 @@ export class MailRuleEditDialogComponent extends EditDialogComponent { filter_attachment_filename_exclude: new FormControl(null), maximum_age: new FormControl(null), attachment_type: new FormControl(MailFilterAttachmentType.Attachments), - pdf_layout: new FormControl(MailRulePdfLayout.Text_Html), + pdf_layout: new FormControl(MailRulePdfLayout.TextHtml), consumption_scope: new FormControl(MailRuleConsumptionScope.Attachments), order: new FormControl(null), action: new FormControl(MailAction.MarkRead), diff --git a/src-ui/src/app/data/mail-rule.ts b/src-ui/src/app/data/mail-rule.ts index c93dfdfa1..1f7a5a80e 100644 --- a/src-ui/src/app/data/mail-rule.ts +++ b/src-ui/src/app/data/mail-rule.ts @@ -12,10 +12,10 @@ export enum MailRuleConsumptionScope { } export enum MailRulePdfLayout { - Text_Html = 1, - Html_Text = 2, - Html_only = 3, - Text_only = 4, + TextHtml = 1, + HtmlText = 2, + HtmlOnly = 3, + TextOnly = 4, } export enum MailAction { diff --git a/src/paperless_mail/parsers.py b/src/paperless_mail/parsers.py index 5c2622a52..44032a2e9 100644 --- a/src/paperless_mail/parsers.py +++ b/src/paperless_mail/parsers.py @@ -127,7 +127,7 @@ class MailDocumentParser(DocumentParser): document_path: Path, mime_type: str, file_name=None, - mailrule: int | None = None, + mailrule_id: int | None = None, ): """ Parses the given .eml into formatted text, based on the decoded email. @@ -187,8 +187,8 @@ class MailDocumentParser(DocumentParser): self.date = mail.date self.log.debug("Creating a PDF from the email") - if mailrule: - rule = MailRule.objects.get(pk=mailrule) + if mailrule_id: + rule = MailRule.objects.get(pk=mailrule_id) self.archive_path = self.generate_pdf(mail, rule.pdf_layout) else: self.archive_path = self.generate_pdf(mail) @@ -266,15 +266,13 @@ class MailDocumentParser(DocumentParser): route.pdf_format(pdf_a_format) match pdf_layout: - case MailRule.PdfLayout.TEXT_HTML: - route.merge([mail_pdf_file, pdf_of_html_content]) case MailRule.PdfLayout.HTML_TEXT: route.merge([pdf_of_html_content, mail_pdf_file]) case MailRule.PdfLayout.HTML_ONLY: route.merge([pdf_of_html_content]) case MailRule.PdfLayout.TEXT_ONLY: route.merge([mail_pdf_file]) - case _: + case MailRule.PdfLayout.TEXT_HTML | _: route.merge([mail_pdf_file, pdf_of_html_content]) try: