Skip to content
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

allow and check for regex in email suppression #4936

Merged
merged 3 commits into from
Aug 2, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app/marketing/migrations/0004_auto_20190801_1303.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.3 on 2019-08-01 13:03

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('marketing', '0003_auto_20190720_1709'),
]

operations = [
migrations.AlterField(
model_name='emailsupressionlist',
name='email',
field=models.TextField(max_length=255),
),
]
2 changes: 1 addition & 1 deletion app/marketing/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def __str__(self):

class EmailSupressionList(SuperModel):

email = models.EmailField(max_length=255)
email = models.TextField(max_length=255)
metadata = JSONField(default=dict, blank=True)
comments = models.TextField(max_length=5000, blank=True)

Expand Down
8 changes: 7 additions & 1 deletion app/marketing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import requests
from mailchimp3 import MailChimp
from marketing.models import AccountDeletionRequest, LeaderboardRank
from marketing.models import AccountDeletionRequest, EmailSupressionList, LeaderboardRank
from slackclient import SlackClient
from slackclient.exceptions import SlackClientError

Expand Down Expand Up @@ -201,6 +201,12 @@ def should_suppress_notification_email(email, email_type):


def get_or_save_email_subscriber(email, source, send_slack_invite=True, profile=None):
# Prevent syncing for those who match the suppression list
suppressions = EmailSupressionList.objects.all()
for suppression in suppressions:
if re.match(suppression, email):
return None

from marketing.models import EmailSubscriber
defaults = {'source': source, 'email': email}

Expand Down