mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 03:41:05 -05:00
Internal: validate AnymailRecipientStatus at init
Catch invalid message_id and status when initializing AnymailRecipientStatus, so problems with ESP response are caught earlier (in individual backend parse_recipient_status, rather than base backend _send).
This commit is contained in:
@@ -85,6 +85,14 @@ class AnymailRecipientStatus:
|
||||
"""Information about an EmailMessage's send status for a single recipient"""
|
||||
|
||||
def __init__(self, message_id, status):
|
||||
try:
|
||||
# message_id must be something that can be put in a set
|
||||
# (see AnymailStatus.set_recipient_status)
|
||||
set([message_id])
|
||||
except TypeError:
|
||||
raise TypeError("Invalid message_id %r is not scalar type" % message_id)
|
||||
if status is not None and status not in ANYMAIL_STATUSES:
|
||||
raise ValueError("Invalid status %r" % status)
|
||||
self.message_id = message_id # ESP message id
|
||||
self.status = status # one of ANYMAIL_STATUSES, or None for not yet sent to ESP
|
||||
|
||||
|
||||
Reference in New Issue
Block a user