NAS: syndicated ads click through our redirect so network clicks count and carry the source site

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-10 10:16:22 -05:00
parent ecdee89be1
commit 82269eccc8
+9 -2
View File
@@ -75,7 +75,8 @@ async function pushCampaign(c, opts = {}) {
(Username, Subject, Body, WebsiteURL, assigned, remaining, hits, approved, Date, adtype,
Name, Email, PaymentDetails, EDate, sp, width, height, BannerURL, pid, ref_by, catid)
VALUES (?,?,?,?,?,?,0,1,?,?,?,?,?,?,'',?,?,?,?,0,?)`,
[token, c.title || null, c.type === 'text' ? (c.body || null) : null, c.targetUrl,
// clicks route through our redirect so they count and carry the network site as the referrer
[token, c.title || null, c.type === 'text' ? (c.body || null) : null, 'https://instantadpay.com/api/ads/click/' + c.id,
assigned, assigned, now, kind.adtype,
opts.name || 'InstantAdPay member', opts.email || 'ads@instantadpay.com',
'InstantAdPay campaign #' + c.id, edate,
@@ -107,6 +108,12 @@ async function deactivate(nasAdId) {
}
// top up a syndicated ad with more impressions (buy-more-views / reactivate).
// point an existing NAS ad at our click redirect (migration for rows pushed before 2026-09-10)
async function setClickUrl(nasAdId, campaignId) {
if (!enabled()) return { skipped: 'flag-off' };
await q('UPDATE sponsorads SET WebsiteURL=? WHERE ID=?', ['https://instantadpay.com/api/ads/click/' + Number(campaignId), Number(nasAdId)]);
return { ok: true };
}
async function topUp(nasAdId, addImpressions, days) {
if (!enabled()) return { skipped: 'flag-off' };
await q(`UPDATE sponsorads SET assigned=assigned+?, remaining=remaining+?, approved=1,
@@ -115,4 +122,4 @@ async function topUp(nasAdId, addImpressions, days) {
return { ok: true };
}
module.exports = { enabled, pushCampaign, readServed, deactivate, topUp, impressionsPerCredit, nasKind };
module.exports = { setClickUrl, enabled, pushCampaign, readServed, deactivate, topUp, impressionsPerCredit, nasKind };