fix listmonk authentication
This commit is contained in:
parent
270200cac3
commit
f84d0238f0
1 changed files with 6 additions and 6 deletions
|
|
@ -92,23 +92,23 @@ def add_email(email):
|
||||||
|
|
||||||
def delete_bounced_emails():
|
def delete_bounced_emails():
|
||||||
url = settings.LISTMONK_API + 'bounces'
|
url = settings.LISTMONK_API + 'bounces'
|
||||||
auth = (settings.LISTMONK_USER, settings.LISTMONK_PASSWORD)
|
auth = get_auth(headers)
|
||||||
r = requests.get(url + '?per_page=10000', auth=auth).json()
|
r = requests.get(url + '?per_page=10000', headers=headers, auth=auth).json()
|
||||||
ids = [sub['subscriber_id'] for sub in r['data']['results']]
|
ids = [sub['subscriber_id'] for sub in r['data']['results']]
|
||||||
url = settings.LISTMONK_API + 'subscribers'
|
url = settings.LISTMONK_API + 'subscribers'
|
||||||
for id in ids:
|
for id in ids:
|
||||||
r = requests.delete(url + '?id=%s' % id, auth=auth).json()
|
r = requests.delete(url + '?id=%s' % id, headers=headers, auth=auth).json()
|
||||||
if not r.get("data"):
|
if not r.get("data"):
|
||||||
print(id)
|
print(id)
|
||||||
|
|
||||||
|
|
||||||
def delete_blacklisted_emails():
|
def delete_blacklisted_emails():
|
||||||
url = settings.LISTMONK_API + 'subscribers'
|
url = settings.LISTMONK_API + 'subscribers'
|
||||||
auth = (settings.LISTMONK_USER, settings.LISTMONK_PASSWORD)
|
auth = get_auth(headers)
|
||||||
r = requests.get(url + '?per_page=10000', auth=auth).json()
|
r = requests.get(url + '?per_page=10000', headers=headers, auth=auth).json()
|
||||||
ids = [u['id'] for u in r['data']['results'] if u['status'] == 'blocklisted']
|
ids = [u['id'] for u in r['data']['results'] if u['status'] == 'blocklisted']
|
||||||
for id in ids:
|
for id in ids:
|
||||||
r = requests.delete(url + '?id=%s' % id, auth=auth).json()
|
r = requests.delete(url + '?id=%s' % id, headers=headers, auth=auth).json()
|
||||||
if not r.get("data"):
|
if not r.get("data"):
|
||||||
print(id)
|
print(id)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue