mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 03:41:05 -05:00
SendGrid: change message_id from Message-ID/smtp-id to UUID anymail_id
SendGrid does not always correctly provide the sent Message-ID header value to a tracking webhook's smtp-id field, making it unreliable to use for Anymail's `message_id`. Instead, generate a UUID `message_id` for Anymail tracking, and pass it from send to webhooks in SendGrid custom args as anymail_id. Webhooks will fall back to smtp-id for compatibility with previously-sent messages that didn't have an anymail_id custom arg. Fixes #108
This commit is contained in:
committed by
Mike Edmunds
parent
51d2a404c0
commit
d8d1407c61
@@ -4,6 +4,7 @@ import logging
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import uuid
|
||||
import warnings
|
||||
from base64 import b64decode
|
||||
from contextlib import contextmanager
|
||||
@@ -165,6 +166,14 @@ class AnymailTestMixin:
|
||||
second = rfc822_unfold(second)
|
||||
self.assertEqual(first, second, msg)
|
||||
|
||||
def assertUUIDIsValid(self, uuid_str, version=4):
|
||||
"""Assert the uuid_str evaluates to a valid UUID"""
|
||||
try:
|
||||
uuid.UUID(uuid_str, version=version)
|
||||
except (ValueError, AttributeError, TypeError):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
# Backported from Python 3.4
|
||||
class _AssertLogsContext(object):
|
||||
|
||||
Reference in New Issue
Block a user