list management
This commit is contained in:
parent
55202ba3b0
commit
502f6fb2b9
1 changed files with 12 additions and 1 deletions
|
@ -81,7 +81,7 @@ def add_email(email):
|
|||
def delete_bounced_emails():
|
||||
url = settings.LISTMONK_API + 'bounces'
|
||||
auth = (settings.LISTMONK_USER, settings.LISTMONK_PASSWORD)
|
||||
r = requests.get(url + '?per_page=10000', auth=auth)
|
||||
r = requests.get(url + '?per_page=10000', auth=auth).json()
|
||||
ids = [sub['subscriber_id'] for sub in r['data']['results']]
|
||||
url = settings.LISTMONK_API + 'subscribers'
|
||||
for id in ids:
|
||||
|
@ -90,3 +90,14 @@ def delete_bounced_emails():
|
|||
print(id)
|
||||
|
||||
|
||||
def delete_blacklisted_emails():
|
||||
url = settings.LISTMONK_API + 'subscribers'
|
||||
auth = (settings.LISTMONK_USER, settings.LISTMONK_PASSWORD)
|
||||
r = requests.get(url + '?per_page=10000', auth=auth).json()
|
||||
ids = [u['id'] for u in r['data']['results'] if u['status'] == 'blocklisted']
|
||||
for id in ids:
|
||||
r = requests.delete(url + '?id=%s' % id, auth=auth).json()
|
||||
if not r.get("data"):
|
||||
print(id)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue