Skip to content

Commit b3d8d7b

Browse files
committed
add shim for legacy mixed_subtype
1 parent e959fd9 commit b3d8d7b

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/herald/base.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from mimetypes import guess_type
55

66
import jsonpickle
7+
import django
78
from django.conf import settings
89
from django.contrib.sites.models import Site
910
from django.core.files import File
@@ -14,6 +15,10 @@
1415

1516
from herald.utils import get_sent_notification_model
1617

18+
use_legacy_mixed_subtype: bool = False
19+
if django.VERSION < (5, 0):
20+
use_legacy_mixed_subtype: bool = True
21+
1722

1823
class NotificationBase:
1924
"""
@@ -451,7 +456,8 @@ def _send(
451456
# All mimebase attachments must have a Content-ID or Content-Disposition header
452457
# or they will show up as unnamed attachments"
453458
if isinstance(attachment, MIMEBase):
454-
if attachment.get("Content-ID", False):
459+
# `mixed_subtype` was removed from Django 5+
460+
if use_legacy_mixed_subtype and attachment.get("Content-ID", False):
455461
# if you are sending attachment with content id,
456462
# subtype must be 'related'.
457463
mail.mixed_subtype = "related"

0 commit comments

Comments
 (0)