Spamhaus DBL cleanup (2026-11-17): close the ad-click redirector, mail links on the share domain
- /api/ads/click/<id> only redirects off-site for an active campaign (or its owner). Ended, paused, archived and flagged campaigns (488 of them, e.g. #164 -> shrt1.xyz) kept forwarding forever, a standing instantadpay.com redirector. They now land on the home page, uncounted. - mailer.js rewrites every instantadpay.com URL in subject/text/html and List-Unsubscribe to MAIL_BASE (default https://instantadpay.link; '' = off). Email addresses and subdomains untouched. - Share hosts answer /unsubscribe (GET + RFC 8058 POST) and /banners/* in place; leaderboard, blog, presentation, partners, launch, plays, bixpay, wall are pages, not usernames (none taken). - NAS syndicated ad click URLs go out on instantadpay.link (NAS_CLICK_BASE) for new pushes. - toolkit.js member links (AI writer, handout QR, split-test, partner promo) use shareDomain. - my.js: banner "copy URL" on the share domain; bridge link (Wednesday/Friday) now builds from the share-form invite line (it silently fell back to the plain invite). my.js?v=20261117dbl. iap-qa member: 0 bugs; networksso-partner e2e all passed on rerun. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Outbound mail via SendGrid v3 (domain-authenticated instantadpay.com).
|
||||
// Outbound mail via SendGrid v3 (domain-authenticated instantadpay.com; links in bodies go out on the share domain, see mailLinks).
|
||||
// Key sources: SENDGRID_KEY env, else DATA_DIR/sendgrid.key in the volume.
|
||||
// No key = email sign-in stays feature-flagged off in production.
|
||||
const fs = require('fs');
|
||||
@@ -19,6 +19,17 @@ function hasKey() { return !!key(); }
|
||||
// codes and mail to the admin is skipped for anyone who unsubscribed, carries
|
||||
// the signed unsubscribe link (appended unless the body already has one) and
|
||||
// RFC 8058 one-click List-Unsubscribe headers. New senders inherit this.
|
||||
// Links in mail go on the share domain (2026-11-17, Spamhaus DBL): instantadpay.com is on the DBL, so every URL to it in a body
|
||||
// (and the List-Unsubscribe header) counts against each email. One rewrite here covers every sender; the share host passes
|
||||
// /my, /ledger, /join/<tok>, ... through to the same page and answers /unsubscribe and /banners/* itself. The From address
|
||||
// and any name@instantadpay.com in the text stay as they are. MAIL_BASE='' turns it off.
|
||||
const MAIL_BASE = String(process.env.MAIL_BASE == null ? 'https://instantadpay.link' : process.env.MAIL_BASE).trim().replace(/\/+$/, '');
|
||||
const IAP_LINK_RE = /(?<![@\w.-])(?:https?:\/\/)?(?:www\.)?instantadpay\.com(?![\w-])/gi;
|
||||
function mailLinks(s) {
|
||||
if (!MAIL_BASE || s == null) return s;
|
||||
const bare = MAIL_BASE.replace(/^https?:\/\//, '');
|
||||
return String(s).replace(IAP_LINK_RE, m => /^https?:/i.test(m) ? MAIL_BASE : bare);
|
||||
}
|
||||
function isAdmin(to) { const a = String(process.env.ADMIN_EMAIL || '').trim().toLowerCase(); return !!a && String(to).trim().toLowerCase() === a; }
|
||||
|
||||
async function send(to, subject, text, html, opts) { // html optional (2026-10-01): sent alongside the plain text, never instead of it
|
||||
@@ -29,6 +40,7 @@ async function send(to, subject, text, html, opts) { // html optional (2026-10-0
|
||||
try { if (await drip.isUnsubscribed(to)) return false; } catch (e) { console.error('mailer opt-out check', e.message); }
|
||||
try { unsub = drip.unsubUrl(to); } catch (e) { console.error('mailer unsub link', e.message); }
|
||||
}
|
||||
unsub = mailLinks(unsub); text = mailLinks(text); if (html) html = mailLinks(html); subject = mailLinks(subject);
|
||||
if (unsub && !String(text).includes('/unsubscribe?')) text = text + '\n\n--\nStop these emails: ' + unsub;
|
||||
if (unsub && html && !String(html).includes('/unsubscribe?')) {
|
||||
const foot = '<p style="font-size:12px;color:#888;margin-top:24px">Stop these emails: <a href="' + unsub + '" style="color:#888">unsubscribe</a></p>';
|
||||
@@ -68,4 +80,4 @@ function sendCode(to, code) {
|
||||
+ 'InstantAdPay\nAdvertise and earn instantly. Locked in code, not promises.\nhttps://instantadpay.com', null, { transactional: true });
|
||||
}
|
||||
|
||||
module.exports = { init, hasKey, send, sendCode };
|
||||
module.exports = { init, hasKey, send, sendCode, mailLinks };
|
||||
|
||||
Reference in New Issue
Block a user