From f875d94d5193c0d6d30c499f795d9f5beef6f05a Mon Sep 17 00:00:00 2001 From: martbost Date: Sun, 18 Oct 2026 05:15:14 -0500 Subject: [PATCH] Ads viewer: "View an ad" no longer says "no member ads" on every second press The viewer alternates banner/text requests; with only one type live, every other press came back empty. /api/my/earnview now treats the type as a preference and falls back to the other type before answering none. Co-Authored-By: Claude Opus 5.5 --- server.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 4be1410..91fa18c 100644 --- a/server.js +++ b/server.js @@ -2355,7 +2355,10 @@ const server = http.createServer(async (req, res) => { if (status.views >= status.target || status.claimed) return json(res, 200, { ad: null, status }); const type = String(u.searchParams.get('type') || 'banner'); // members never see (or earn from) their own campaigns in the viewer - const ad = await ads.serve(type === 'text' ? 'text' : 'banner', Object.assign({ excludeEmail: s.email }, viewerGeo(req), audiences.matcher(req))); + const want = type === 'text' ? 'text' : 'banner', vopts = Object.assign({ excludeEmail: s.email }, viewerGeo(req), audiences.matcher(req)); + // the type is a preference, not a filter: the viewer alternates banner/text, so with only one type live every + // second press said "no member ads" (tester, 2026-10-18). Fall back to the other type before saying none. + const ad = (await ads.serve(want, vopts)) || (await ads.serve(want === 'text' ? 'banner' : 'text', vopts)); if (!ad) return json(res, 200, { ad: null, status }); const token = crypto.randomBytes(16).toString('hex'); // the viewer tab frames the advertiser's REAL url (no click counted for a paid view)