ignore mailchimp errors
authorJan Szejko <janek37@gmail.com>
Thu, 6 Sep 2018 12:59:48 +0000 (14:59 +0200)
committerJan Szejko <janek37@gmail.com>
Thu, 6 Sep 2018 12:59:48 +0000 (14:59 +0200)
contact/mailing.py

index bfd4209..fc40a10 100644 (file)
@@ -41,12 +41,15 @@ def subscribe(email):
     else:
         if member['status'] != 'subscribed':
             remove_from_groups(email, client)
-    client.lists.members.create_or_update(
-        settings.MAILCHIMP_LIST_ID, subscriber_hash(email),
-        data={
-            'email_address': email,
-            'status_if_new': 'subscribed',
-            'status': 'subscribed',
-            'interests': INTERESTS,
-        }
-    )
+    try:
+        client.lists.members.create_or_update(
+            settings.MAILCHIMP_LIST_ID, subscriber_hash(email),
+            data={
+                'email_address': email,
+                'status_if_new': 'subscribed',
+                'status': 'subscribed',
+                'interests': INTERESTS,
+            }
+        )
+    except MailChimpError:
+        pass