From e1c0bf50306acd65fa24feb88ab46c928fc5c13b Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Wed, 12 Jul 2023 23:09:10 +0530 Subject: [PATCH] Fix unsubbed subscribers not getting re-sub optin confirmation. Closes #1315. --- queries.sql | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/queries.sql b/queries.sql index d0ffa9a..a48514d 100644 --- a/queries.sql +++ b/queries.sql @@ -169,7 +169,15 @@ INSERT INTO subscriber_lists (subscriber_id, list_id, status) (CASE WHEN $4='blocklisted' THEN 'unsubscribed'::subscription_status ELSE $8::subscription_status END) ) ON CONFLICT (subscriber_id, list_id) DO UPDATE - SET status = (CASE WHEN $4='blocklisted' THEN 'unsubscribed'::subscription_status ELSE subscriber_lists.status END); + SET status = ( + CASE + WHEN $4='blocklisted' THEN 'unsubscribed'::subscription_status + -- When subscriber is edited from the admin form, retain the status. Otherwise, a blocklisted + -- subscriber when being re-enabled, their subscription statuses change. + WHEN $9 = TRUE THEN subscriber_lists.status + ELSE $8::subscription_status + END + ); -- name: delete-subscribers -- Delete one or more subscribers by ID or UUID.