fix(app): Ignore SCOTUS/Texas emails from other SES rules#35
Conversation
Verify that the destination subscription subdomain matches the source court domain before routing. Emails from sc-us.gov or txcourts.gov arriving via the generic recap.email SES rule are now ignored to avoid double processing and race conditions. Closes #34 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
albertisfu
left a comment
There was a problem hiding this comment.
Thanks @MorganBennetDev this looks great I just have a small suggestion, please.
| for destination in email.get("destination", []): | ||
| dest_parts = parseaddr(destination)[1].split("@") | ||
| if len(dest_parts) != 2: | ||
| return False | ||
| dest_domain = dest_parts[1].lower() | ||
| if dest_domain != required and not dest_domain.endswith( | ||
| f".{required}" | ||
| ): | ||
| return False | ||
| return True |
There was a problem hiding this comment.
This might be weird, but if someday PACER, TAMES, or SCOTUS sends messages with more than one destination by mistake, like ['notifications@scotus.recap.email', 'no_reply@sc-us.gov'], the message will be dropped even though it was properly sent to our email address, because the second address would make this fail.
I think we can invert the logic to be more cautious so that we return True for any match and False only if there’s no match at all.
albertisfu
left a comment
There was a problem hiding this comment.
Thanks @MorganBennetDev this looks great I just have a small suggestion, please.
albertisfu
left a comment
There was a problem hiding this comment.
Thanks @MorganBennetDev this looks great.
I'll be deploying this changed to the lambda.
Verify that the destination subscription subdomain matches the source court domain before routing. Emails from sc-us.gov or txcourts.gov must be sent to a
@scotus.recap.emailor@texas.recap.emailaddress respectively or they will be ignored.Closes #34