Skip to content

Commit

Permalink
allow and check for regex in email suppression
Browse files Browse the repository at this point in the history
  • Loading branch information
danlipert committed Aug 1, 2019
1 parent d417243 commit 4082640
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
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),
),
]
3 changes: 2 additions & 1 deletion app/marketing/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,10 @@ 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)

def __str__(self):
return f"{self.email}"

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

0 comments on commit 4082640

Please sign in to comment.