From f84d0238f0db61aafaaedcafe8c8169a6d321deb Mon Sep 17 00:00:00 2001 From: j Date: Sun, 9 Feb 2025 19:35:41 +0000 Subject: [PATCH] fix listmonk authentication --- app/listmonk/utils.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/listmonk/utils.py b/app/listmonk/utils.py index 805ee64..0ea078f 100644 --- a/app/listmonk/utils.py +++ b/app/listmonk/utils.py @@ -92,23 +92,23 @@ 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).json() + auth = get_auth(headers) + r = requests.get(url + '?per_page=10000', headers=headers, auth=auth).json() ids = [sub['subscriber_id'] for sub in r['data']['results']] url = settings.LISTMONK_API + 'subscribers' 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"): 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() + auth = get_auth(headers) + 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'] 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"): print(id)