Member updates: audience defaults to newsletter opt-ins (Sendy list status), explicit 'everyone' option; sendy.status()

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-14 13:47:13 -05:00
parent 7bb956e896
commit 024170e7f8
5 changed files with 29 additions and 8 deletions
+14 -1
View File
@@ -35,4 +35,17 @@ function subscribe(email, name) {
});
}
module.exports = { subscribe, enabled };
// 'Subscribed' | 'Unsubscribed' | 'Unconfirmed' | 'Bounced' | 'Soft bounced' | 'Complained' | 'Email does not exist in list' | '' (no key / unreachable)
function status(email) {
const key = apiKey(); const e = String(email || '').trim();
if (!key || !e) return Promise.resolve('');
const body = new URLSearchParams({ api_key: key, email: e, list_id: LIST }).toString();
const u = new URL(URL_BASE + '/api/subscribers/subscription-status.php');
return new Promise(resolve => {
const req = https.request({ hostname: u.hostname, path: u.pathname, method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': Buffer.byteLength(body) }, timeout: 10000 },
res => { let d = ''; res.on('data', c => d += c); res.on('end', () => resolve(d.trim().slice(0, 60))); });
req.on('error', () => resolve('')); req.on('timeout', () => { req.destroy(); resolve(''); }); req.end(body);
});
}
module.exports = { subscribe, enabled, status };