newsletter: the unsubscribe PUT needs the email field — it was a silent 400

The end-to-end probe against the live listmonk caught this: PUT
/api/subscribers/{id} with {"lists": []} returns 400 {"message":"Invalid
email."}, leaving the subscriber on the list. It needs {"email": ..., "lists":
[]}. The failed request was only a log warning, so the reconcile's main job —
taking lapsed members off the Members list — has never worked; only the DELETE
branch did anything, which is the branch this series just removed.

Now both classes unsubscribe successfully and keep their record.
This commit is contained in:
Ubuntu committed 2026-10-26 16:42:10 +00:00
1 parent 7bb676eb68
commit 9495daa701
1 file changed
+4 -1
+4 -1
View File
@@ -482,10 +482,13 @@ async def listmonk_reconcile() -> dict:
# Both classes leave the list the same way: unsubscribe, keep the
# record. Nothing is deleted.
reason = "inactive member" if email in member_emails else "not a member"
# listmonk validates the PUT body's email field: omitting it is a
# 400 "Invalid email." and the subscriber stays on the list (which
# is why the inactive-member branch never actually worked).
r = await client.put(
f"{LISTMONK_BASE}/api/subscribers/{sid}",
headers=auth,
json={"lists": []},
json={"email": s.get("email"), "lists": []},
)
if r.status_code in (200, 201):
removed += 1