-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MPP-3932: Add flag 'developer_mode', use to simulate complaint and log notifications #5090
Conversation
emails/views.py
Outdated
notification_gza85 = base64.a85encode( | ||
zlib.compress(json.dumps(notification).encode()), wrapcol=1024, pad=True | ||
).decode("ascii") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quesgestion (non-blocking): can this sequence of base64
, zlib
, and json
calls be moved into a helper function format_notification_for_log
that can help with re-using it exactly the same way each time? E.g., in the test code?
Added |
Add a new waffle flag 'developer_mode', that enables additional logging for the user. This logging goes beyond our user privacy policy, so it should only be enabled for Relay staff with consent. In addition, special mask labels are used to limit logging for forwarded emails.
For forwarded mail, the mask label is used to determine developer actions. If the mask contains
DEV:simulate_complaint
(no spaces), then the mail is forwarded to the AWS complaint simulator address instead of the user's real address. If the mask containsDEV:
(which includes (DEV:simulate_complaint
)), the received notification itself is logged, using zlib.compress and base64.a85encode to reduce the size. If the encoded notification is more than 1024 bytes, the message is split over several log lines.For complaints, any complaint notification for the user is logged. When we can reliably detect the mask, we may change this to use the mask label to further limit logging.
How to test:
I wrote tests for the new functionality in handling forwards and complaints.
I refactored the
ComplaintHandlingTest
to add themail
element to all test complaint notifications, and to use the forwarded "russian spam" fixture instead of the incoming version. This required some other changes to mock aDate
header, added by SES when forwarding the email.I did not manually test this code. I plan to test it on the dev server, where we can set flags and debug the results.