Link-farm hardening (2026-10-30 incident: 106 free accounts used casino bios and website links as backlinks; Google indexed the text through /wall pages)

Public walls: profile fields (bio, avatar, socials, intro video) render only for a paying member (memberId > 0 or a registered position), on /api/wall and in the OG image; a free account's wall shows the name, the line's ads and the join call. The meta/og description is a fixed site sentence with the handle, never the bio. Outbound profile links are rel="sponsored ugc noopener" target="_blank". A deleted or unknown name is a real 404 with X-Robots-Tag noindex (was a bare "Banner wall" page at 200, a soft 404 that stayed indexed).

Policy (prohibited.js, byte-for-byte copy on LinkSpin): bios may not carry a URL or a domain token ("Links go in the social fields, not the bio"); gambling, adult, pharma, weapons and link-selling terms (Unicode aware, Vietnamese and Portuguese terms included) are refused in bios, social URLs, line banner targets, wall offers and every campaign field, with the refusal logged. lssync applies it on the way out and lsinbound on ingest.

Quarantine rule: a brand-new free account (no wallet, no sponsor, under 24 h) whose first profile save plants a link is saved with profileQuarantined (JSON + MySQL column), never rendered publicly, and told "Your profile links will appear after your first ad package"; the admin member card shows the flag.

Daily link-farm scan (spamscan.js, same copy on LinkSpin): in-app job at 06:30 Central, claimOnce per day, lists memberId-0 walletless accounts with a link plus a farm signal (prohibited term, sign-in over within 15 min, no sponsor), skips the spamScanAllow setting (seeded), writes DATA_DIR/wall-spam-scan.json and sends one Telegram to the private admin chat only when there are candidates. Admin > Members > Link-farm list: rows with "also on LinkSpin", Delete selected (existing DELETE /api/admin/member, on-chain refused, no cascade) and Allow.

Terms section 8 "Prohibited content", bio hint in the profile editor, chatbot canned answer "What content is not allowed?", KNOWLEDGE_DATE 2026-10-30. Test: qa/profile-policy.test.cjs (unit + local copy; runs in qa/run.sh member and policy).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-30 07:29:11 -05:00
parent ec4ada08d7
commit 337d4f9e8f
18 changed files with 615 additions and 36 deletions
+7 -4
View File
@@ -37,6 +37,7 @@ const pub = a => a ? { email: a.email, sponsorRef: a.sponsorRef || '', code: a.c
lineBannerUrl: a.lineBannerUrl || null, lineTargetUrl: a.lineTargetUrl || null, wallOffers: a.wallOffers || null,
avatarUrl: a.avatarUrl || null, bio: a.bio || null, socials: a.socials || null,
bixPartnerLink: a.bixPartnerLink || null, // BixPay partner link (bixpay.js, 2026-10-29): one identity, follows the member to LinkSpin/CTB
profileQuarantined: !!a.profileQuarantined, // 2026-10-30: first profile save of a brand-new free account planted a link; stored, never rendered publicly (spamscan.js)
chatAvailable: a.chatAvailable === false ? false : true, lastSeen: a.lastSeen || 0,
address: a.address || null, created: a.created } : null;
const USER_RE = /^[a-zA-Z0-9_]{3,20}$/;
@@ -117,12 +118,13 @@ const J = {
acct.wallOffers = json || null; this.save();
return { ok: true, account: pub(acct) };
},
async setProfile(e, avatarUrl, bio, socials) {
async setProfile(e, avatarUrl, bio, socials, quarantined) {
const acct = this.db.byEmail[e];
if (!acct) return { error: 'No such account.' };
if (avatarUrl !== undefined) acct.avatarUrl = avatarUrl || null;
if (bio !== undefined) acct.bio = bio || null;
if (socials !== undefined) acct.socials = socials || null;
if (quarantined !== undefined) acct.profileQuarantined = !!quarantined;
this.save();
return { ok: true, account: pub(acct) };
},
@@ -230,7 +232,7 @@ const J = {
const rowPub = r => r ? pub({ email: r.email, sponsorRef: r.sponsor_ref, code: r.code,
username: r.username, memberId: r.member_id || 0, joinedVia: r.joined_via || null, joinedRef: r.joined_ref || null,
lineBannerUrl: r.line_banner_url, lineTargetUrl: r.line_target_url, wallOffers: r.wall_offers || null,
avatarUrl: r.avatar_url, bio: r.bio, socials: r.socials, bixPartnerLink: r.bix_partner_link || null,
avatarUrl: r.avatar_url, bio: r.bio, socials: r.socials, bixPartnerLink: r.bix_partner_link || null, profileQuarantined: !!r.profile_quarantined,
chatAvailable: r.chat_available === 0 ? false : true, lastSeen: Number(r.last_seen || 0),
address: r.address, created: Number(r.created) }) : null;
const D = {
@@ -285,10 +287,11 @@ const D = {
await db.q('UPDATE accounts SET wall_offers=? WHERE email=?', [json || null, e]);
return { ok: true, account: await this.byEmail(e) };
},
async setProfile(e, avatarUrl, bio, socials) {
async setProfile(e, avatarUrl, bio, socials, quarantined) {
if (avatarUrl !== undefined) await db.q('UPDATE accounts SET avatar_url=? WHERE email=?', [avatarUrl || null, e]);
if (bio !== undefined) await db.q('UPDATE accounts SET bio=? WHERE email=?', [bio || null, e]);
if (socials !== undefined) await db.q('UPDATE accounts SET socials=? WHERE email=?', [socials || null, e]);
if (quarantined !== undefined) await db.q('UPDATE accounts SET profile_quarantined=? WHERE email=?', [quarantined ? 1 : 0, e]);
return { ok: true, account: await this.byEmail(e) };
},
async setBixLink(e, link) { const r = await db.q('UPDATE accounts SET bix_partner_link=? WHERE email=?', [link || null, e]); if (!r || !r.affectedRows) return { error: 'No such account.' }; return { ok: true, account: await this.byEmail(e) }; },
@@ -506,7 +509,7 @@ module.exports = { init, signup, login, ensure, onChange, isUnclaimedShell, byEm
setUsername, reservedUsername, setMemberId, namesForMembers, listByReferrer, downline, linkWallet, count,
setLineBanner: (e, b, t) => impl().setLineBanner(String(e || '').toLowerCase(), b, t),
setWallOffers: (e, j) => impl().setWallOffers(String(e || '').toLowerCase(), j),
setProfile: async (e, a, bio, socials) => { const r = await impl().setProfile(String(e || '').toLowerCase(), a, bio, socials); if (!(r && r.error)) changed(String(e || '').toLowerCase()); return r; }, // profile edits reach LinkSpin too
setProfile: async (e, a, bio, socials, quarantined) => { const r = await impl().setProfile(String(e || '').toLowerCase(), a, bio, socials, quarantined); if (!(r && r.error)) changed(String(e || '').toLowerCase()); return r; }, // profile edits reach LinkSpin too
setBixLink: async (e, link) => { const r = await impl().setBixLink(normEmail(e), link ? String(link).slice(0, 300) : null); if (!(r && r.error)) changed(normEmail(e)); return r; }, // the BixPay partner link rides to LinkSpin in the profile row (lssync.js)
touchSeen: e => impl().touchSeen(String(e || '').toLowerCase()),
adminSetAddress: (e, a) => impl().adminSetAddress(String(e || '').toLowerCase(), a ? normAddr(a) : null),
BIN
View File
Binary file not shown.
+5 -1
View File
@@ -33,7 +33,7 @@ function key() {
function enabled() { return !!key(); }
// ---- canned answers: instant, free, always in voice ----
const KNOWLEDGE_DATE = '2026-10-29'; // bump whenever the canned answers / prompt are brought up to date
const KNOWLEDGE_DATE = '2026-10-30'; // bump whenever the canned answers / prompt are brought up to date
const SUPPORT_RE = /(contact|reach|email|e-mail|message|talk to|speak (to|with)|get hold of) (the )?(support|admin|administrator|owner|marty|staff|team at instantadpay|someone|a (human|person|real person))|support (email|address|ticket|team|desk)|help ?desk|(open|send|file|submit|raise) (a )?(support )?ticket|\b(human|real person|live (agent|person|chat|support))\b|customer (service|support)|support@|how (do|can) i get (help|support)/i;
const CANNED = [
{ id: 'support', title: 'Contact support or open a ticket', q: ['How do I contact support?', 'How do I talk to a real person?', 'How do I open a support ticket?'], tags: ['support', 'help', 'ticket', 'contact', 'help desk'],
@@ -191,6 +191,9 @@ const CANNED = [
{ id: 'trust-drain', title: 'Trust Wallet "drain your wallet" warning', q: ['Trust Wallet says this transaction will drain my wallet', 'My wallet blocked the purchase'], tags: ['trust wallet', 'drain', 'wallet warning', 'walletconnect'],
re: /(drain (my|your) wallet|stop and go back|trust wallet.*(warn|block|red)|wallet (warning|blocked))/i,
a: 'That red "this transaction will drain your wallet" screen is the wallet\'s own safety rule, not a problem with the purchase: Trust Wallet blocks any transaction that spends most of the POL in the wallet. Ways through: buy a smaller package first, add some POL so the purchase is well under half the balance, or connect a different wallet (MetaMask, Phantom, SafePal have no such block). Extra POL always stays yours. If the next try says WalletConnect disconnected, open Wallet, tap Disconnect, then Connect again. Phantom, SafePal and MetaMask do not have the hard block.' },
{ id: 'prohibited-content', title: 'What content is not allowed?', q: ['What content is not allowed?', 'Can I put a link in my bio?', 'Can I advertise a casino or CBD?'], tags: ['prohibited content', 'rules', 'bio links', 'gambling', 'adult', 'link farm'],
re: /(not allowed|prohibited|forbidden|banned (content|words|niches?)|content (rules|policy)|what (content|ads|niches?) (is|are) (not )?(allowed|ok|accepted)|can i (post|promote|advertise|run) .*(casino|gambling|betting|adult|porn|cbd|weed|pharma|guns?)|link ?farm|backlinks?|links? in (the |my |your )?bio|bio (link|url)|why was my (bio|profile|link) (refused|rejected|blocked))/i,
a: 'Not allowed anywhere on InstantAdPay (ads, campaigns, line banners, wall offers, bios and social links): gambling, casinos, betting, lotteries and sweepstakes; adult or sexual content; drugs and prescription pharmaceuticals; weapons; hate or harassment; malware, phishing and counterfeit goods; misleading financial promises. The bio is text only: no links and no domain names, links go in the social fields in Profile. Your bio, avatar and social links show on your public wall once you have bought a package; free accounts show only their name and the line’s ads there. Accounts created just to place links in profile fields (link farming) are removed without notice, with their profile text. The full list is in the Terms, section 8: https://instantadpay.com/terms#prohibited' },
{ id: 'wall', title: 'Your banner wall and its three positions', q: ['How does my wall work?', 'How do I own wall positions 2 and 3?'], tags: ['wall', 'banner wall', 'positions'],
re: /(wall (page|slots?|positions?)|banner wall|my wall|three (ads|slots) on (my|the) wall)/i,
a: 'Your wall (instantadpay.com/wall/yourname) shows three ads. Position 1 is always your line banner. Positions 2 and 3 show your upline (or InstantAdPay) until you earn them: 2 qualifying buyers ($20 or more) make position 2 yours, 5 make position 3 yours, so a fully qualified member owns the whole page with their own links and offers. Set them in Profile > Your wall; an unlocked slot you leave empty keeps showing your upline until you fill it.' },
@@ -296,6 +299,7 @@ ${passTiersFact()}${refuelFact()}${synFact()}${polminerFact()}${bixFact()}- ROAD
- Ad packages: Micro $5/500 credits, Starter $10/1,000, Activation $20/2,000, Builder $50/5,500, Growth $100/12,000, Leader $250/32,500, Elite $500/70,000. Dollar-priced, settled in POL (Polygon) at the live Chainlink rate. 1 credit = 1 cent of ad delivery.
- Live formats: display banners (per impression), text ads (per impression), full-screen LOGIN ADS (per day: right after a member signs in they land on a sponsor interstitial — they click "Open Ad", the advertiser's page opens in a NEW tab, a countdown runs on the interstitial, and at zero a "Go to dashboard" button appears. Just a CTA link is enough; an optional banner image can be the clickable creative. No framing requirement since it opens in its own tab), WATCH-TO-EARN VIDEO ADS (advertiser uploads an MP4/WebM or gives a direct https .mp4/.webm link and picks a required watch length — 10s/30s/60s — which sets the per-view price; viewers watch in an escape-proof player under Earn credits > Watch videos, the watch time is enforced on the server clock, and they earn credits per completed watch; you never see your own videos), and solo ads. Banner ads also require a size (standard IAB sizes like 728x90, 300x250). Video watching is capped at 8 a day per member and pays 1, 2 or 4 credits for a 10, 30 or 60 second watch. FEATURED LINKS (live): a headline + link in the Featured strip at the top of every member's Overview, booked for 1, 2 or 7 days at 40 credits a day, up to 7 days ahead, at most 10 links sharing any day; flat buy paid when booked; the row shows days left and 'runs through <date>', counts views (one per viewer per hour) and clicks, and offers Extend run. VERIFIED-VISIT PACKS (live): 3 credits per visit, minimum 20 visits, paid up front; each visit is a distinct member who opens the site in a new tab, stays 8 seconds and passes a check, at most 20 visits per member per day; the row shows 'N of M visits delivered' and Buy more visits adds to the pack; the visitor earns 1 credit.
- WALLETS + BUYING POL (Training > Wallets and buying POL, /wallets, members only): preferred MetaMask (recommended; extra accounts for Qualified Start), Phantom (PHANTOM GOTCHA: Polygon is OFF by default; Settings > Active Networks > turn on Polygon, otherwise connect/buy fails or shows the wrong network; seen with Jim Watts' EB team 2026-09-13), SafePal, Coinbase Wallet; Trust works but blocks buys spending most of its POL (keep ~2x). MoonPay flow: connect wallet, Buy packages > "Buy POL with a card" opens MoonPay with POL on Polygon + the member's address prefilled; card/Apple Pay/Google Pay; first-time ID check; minimum order ~$30; buy package cost + 2-3 POL for fees; POL arrives in minutes; then buy. Exchanges: withdraw POL on the Polygon network. Never MATIC on Ethereum, never share the recovery phrase.
- PROHIBITED CONTENT (2026-10-30, Terms section 8, /terms#prohibited): gambling, casinos, betting, lotteries, sweepstakes; adult or sexual content; drugs and prescription pharmaceuticals; weapons; hate or harassment; malware, phishing, counterfeit goods; misleading financial promises. Refused at save time in bios, social links, line banners, wall offers and every campaign field. A bio may not contain a URL or a domain (links go in the social fields). Profile text, avatar and social links appear on the public wall ONLY for members who have bought a package; a free account's wall shows the name, the line's ads and the join button. Link-farm accounts (created to plant links in profile fields) are removed without notice with their profile text.
- INTRO VIDEO ON THE WALL: Profile > social links has an "Intro video" field (YouTube, Vimeo or direct .mp4 link). It embeds on the member's public wall page (/wall/<username>) right under their bio, above the three-level line and the join button.
- HOLDING TANK (Members > My line > Holding tank card): free members who joined with no sponsor wait there; a member who has switched on payouts AND bought their own $20+ package can Adopt one (first come, max 2 open adoptions, 7-day window; if the person never links a wallet or buys, they fall back into the tank; a person can be adopted twice at most). Adopting sets the sponsor, opens a chat and emails the member; their first purchase then binds to the adopter on-chain. Members can also "Release to tank" one of their own free referrals (pay it forward), but NOT someone they adopted less than 3 days ago: an adoption is a commitment, and a dropped adoption still counts toward that person's two-adoption lifetime limit. Releases are posted to the feed and Telegram like pickups. Admin sees the tank under Members.
- TANK ACTIVATION HOLD (2026-10-27, Marty: never default a tank member to the company): a tank member (no sponsor, not activated) can NOT switch on payouts on its own yet (a PURCHASE is NEVER held, Marty 2026-10-27: with no sponsor anywhere a buy goes ahead under the catch position #1); the Wallet tab and Getting started card say "You're being matched with a sponsor. Payouts switch on as soon as someone picks you up (within 24 hours)." with the time left, and the activate button is hidden. The 24-hour clock starts when they link a wallet; they then show at the top of every holding tank with a green "Ready to activate" badge and hours left, and a post goes to the team's Telegram payments topic. If nobody adopts them in 24 hours, the site auto-assigns them to the next eligible adopter in rotation (own $20+ package, fewer than 2 open adoptions, signed in within 7 days, not suspended; least recently auto-assigned first); the adopter gets a chat + email and Telegram shows the pickup marked (auto-assigned). If nobody is eligible they stay on hold and the admin is alerted; never the company. Someone whose same email or wallet already has a sponsor on LinkSpin is placed under that sponsor instead (not one they were released or rescued from). A member who arrived through a sponsor link is never held. Once they have a sponsor the hold lifts by itself. ONE-TAP SWITCH ON PAYOUTS (2026-10-27): every tank assignment (manual adoption or the 24-hour auto-assign) sends the member a chat and an email with a Switch on payouts link, https://instantadpay.com/my?activate=1#wallet; it opens the Wallet tab and starts the normal Activate payouts flow with the new sponsor prefilled (after sign-in, and after linking a wallet if none is linked yet). It never starts while the hold applies or when no sponsor resolves. The site cannot activate for anyone: activation is one free transaction from the member's own wallet. Not activated 24 hours after the assignment: one reminder email to the member with the same link and one notice to the sponsor ("@x hasn't switched on payouts yet; a nudge from you helps"); at 72 hours one last email to the member only; both stop once the member switches on payouts or buys.
+1
View File
@@ -344,6 +344,7 @@ async function bootstrap() {
await alterSafe('ALTER TABLE accounts ADD COLUMN joined_via VARCHAR(20) NULL'); // ?v= angle the lead came in on
await alterSafe('ALTER TABLE accounts ADD COLUMN joined_ref VARCHAR(80) NULL'); // referring domain of the first join-page visit
await alterSafe('ALTER TABLE accounts ADD COLUMN wall_offers VARCHAR(2000) NULL'); // JSON [{title,bannerUrl,targetUrl}] for wall positions 2-3 (unlock at 2 / 5 qualifying buyers)
await alterSafe('ALTER TABLE accounts ADD COLUMN profile_quarantined TINYINT NOT NULL DEFAULT 0'); // 2026-10-30 link-farm rule: first profile save of a new free account carried a link (spamscan.js)
await alterSafe('ALTER TABLE accounts ADD COLUMN bix_partner_link VARCHAR(300) NULL'); // BixPay partner link (bixpay.js, 2026-10-29); column name checked against MySQL 8 reserved words
// help desk (2026-10-16, tickets.js): one shared desk for IAP and, later, LinkSpin; email_message_id threads inbound mail
await q(`CREATE TABLE IF NOT EXISTS tickets (
+5 -2
View File
@@ -25,6 +25,7 @@
// hides someone adopted on LinkSpin and the two-adoptions limit counts both sites.
'use strict';
const SF = require('./sponsorfollow');
const prohibited = require('./prohibited'); // 2026-10-30: policy applied on ingest
const fs = require('fs');
const path = require('path');
@@ -98,8 +99,10 @@ async function fill(a, r, sum) {
}
if (r.profile && A.setProfile) { // same rules as LinkSpin's side: https only, known socials, fills only what is empty
const pf = r.profile, ok = v => /^https:[/][/][^ ]+$/i.test(v) && v.length <= 300;
const av = String(pf.avatarUrl || '').trim(); const bio = String(pf.bio || '').trim().slice(0, 600); let soc = null;
if (pf.socials && typeof pf.socials === 'object') { const c = {}; for (const k of ['facebook', 'twitter', 'youtube', 'instagram', 'tiktok', 'telegram', 'linkedin', 'website', 'video']) { const v = String(pf.socials[k] || '').trim(); if (ok(v)) c[k] = v; } if (Object.keys(c).length) soc = JSON.stringify(c); }
// prohibited-content policy on ingest (2026-10-30): a bio with a link or a prohibited term, or a social carrying one, is dropped, not stored
const cp = prohibited.cleanProfile(pf, 'InstantAdPay'); if (cp.dropped.length) console.log('lsinbound profile dropped', String(a.email).replace(/^(.).*(@.*)$/, '$1***$2'), cp.dropped.join(','));
const av = String(pf.avatarUrl || '').trim(); const bio = cp.bio || ''; let soc = null;
if (cp.socials) { const c = {}; for (const k of ['facebook', 'twitter', 'youtube', 'instagram', 'tiktok', 'telegram', 'linkedin', 'website', 'video']) { const v = String(cp.socials[k] || '').trim(); if (ok(v)) c[k] = v; } if (Object.keys(c).length) soc = JSON.stringify(c); }
const upd = [!a.avatarUrl && ok(av) ? av : undefined, !a.bio && bio ? bio : undefined, !a.socials && soc ? soc : undefined];
if (upd.some(v => v !== undefined)) { const x = await A.setProfile(a.email, upd[0], upd[1], upd[2]); if (!(x && x.error)) { sum.filled++; wrote = true; } }
}
+8 -3
View File
@@ -14,6 +14,7 @@
'use strict';
const crypto = require('crypto');
const SF = require('./sponsorfollow');
const prohibited = require('./prohibited'); // 2026-10-30: a profile that fails the policy never leaves this site
const fs = require('fs');
const path = require('path');
@@ -41,10 +42,12 @@ const carriesNew = r => !!(r.sponsorSetBy || r.tank);
// absolute https URL so the other property can show it; socials as the parsed {platform: url} object.
const PUBLIC = () => String(process.env.PUBLIC_URL || 'https://instantadpay.com').replace(/\/+$/, '');
function profileOf(a) {
let socials = null; try { socials = a.socials ? (typeof a.socials === 'string' ? JSON.parse(a.socials) : a.socials) : null; } catch (e) { socials = null; }
if (a.profileQuarantined) return null; // quarantined (link planted on a brand-new free account): stays here, unseen, until Marty decides
const cp = prohibited.cleanProfile({ avatarUrl: a.avatarUrl, bio: a.bio, socials: a.socials }, 'InstantAdPay'); // policy applied on the way out too
const socials = cp.socials;
const av = String(a.avatarUrl || '').trim();
const avatarUrl = !av ? null : /^https:\/\//i.test(av) ? av : av.startsWith('/') ? PUBLIC() + av : null;
const bio = String(a.bio || '').trim().slice(0, 600) || null;
const bio = cp.bio;
// the BixPay partner link travels too (2026-10-29): LinkSpin shows it read-only ("Edit on InstantAdPay") and resolves the
// same way; only set when there is one, so rows without it keep the hash they had
const bixPartnerLink = String(a.bixPartnerLink || '').trim() || null;
@@ -109,5 +112,7 @@ async function release(email, sent) {
if (pending.has(e) && !timer) { pending.delete(e); touch(e); } // a touch that queued while muted goes now (the hash check drops it when same)
return same;
}
// does LinkSpin know this email? (its row was pushed and recorded) - used by the link-farm admin list, never for a cascade
function knows(email) { const st = load(); return Object.prototype.hasOwnProperty.call(st.hashes || {}, String(email || '').toLowerCase()); }
function adminView() { const st = load(); return { on: on(), url: URL_(), tracked: Object.keys(st.hashes).length, pushed: st.pushed, last: st.last, errors: st.errors, pendingTouches: pending.size }; }
module.exports = { init, touch, tick, adminView, on, mute, release };
module.exports = { init, touch, tick, adminView, on, mute, release, knows };
+108
View File
@@ -0,0 +1,108 @@
// Prohibited-content policy, one module shared by InstantAdPay and LinkSpin (keep the two copies identical).
// 2026-10-30: an SEO backlink farm opened 106 free accounts, each with a casino or local-business bio and a
// website link, and Google indexed that text under our domains through the public walls. Rules (Marty):
// - profile fields are not a free backlink: a bio may not carry a URL or a domain-looking token;
// - gambling, adult, pharma, weapons and link-selling terms are refused in every member-set text field
// (bio, social links, line banner, wall offers, campaign names, headlines, copy and target URLs);
// - case-insensitive and Unicode aware (NFC, lower-cased, letter/number boundaries, so "Essex" never hits "sex").
// Pure functions, no state, no dependencies.
'use strict';
// One entry per term or phrase; spaces match any run of whitespace. Grouped for the Terms page and the admin.
const LIST = {
gambling: ['casino', 'casinos', 'cassino', 'cassinos', 'slots', 'slot gacor', 'betting', 'sportsbook', 'sportsbooks', 'bookmaker', 'bookmakers', 'bookie',
'lottery', 'lotteries', 'lotto', 'poker', 'baccarat', 'roulette', 'blackjack', 'jackpot', 'togel', 'judi', 'judi online', 'apostas', 'apuestas',
'nổ hũ', 'cá cược', 'đổi thưởng', 'xổ số', 'kèo', 'nhà cái', 'soi kèo', 'game bài', 'tài xỉu', 'bắn cá'],
adult: ['porn', 'porno', 'pornography', 'sex', 'sexy', 'escort', 'escorts', 'erotic', 'erotica', 'xxx', 'onlyfans', 'nude', 'nudes', 'hentai', 'cam girl', 'cam girls', 'sex cam', 'hookup', 'hookups'],
pharma: ['viagra', 'cialis', 'levitra', 'pharmacy', 'pharmacies', 'prescription', 'prescriptions', 'steroids', 'anabolic', 'cannabis', 'marijuana', 'weed', 'cbd', 'kratom', 'opioid', 'opioids',
'xanax', 'adderall', 'tramadol', 'oxycodone', 'ketamine', 'cocaine', 'mdma', 'psilocybin', 'vape', 'vaping'],
weapons: ['firearm', 'firearms', 'guns', 'gun shop', 'gun store', 'ammunition', 'ammo', 'rifle', 'rifles', 'pistol', 'pistols', 'handgun', 'handguns', 'silencer', 'suppressor', 'explosives'],
linkfarm: ['backlink', 'backlinks', 'seo service', 'seo services', 'seo agency', 'link building', 'link-building', 'guest post', 'guest posts', 'guest posting', 'pbn', 'buy links', 'sell links', 'dofollow']
};
const ALL = Object.values(LIST).reduce((a, b) => a.concat(b), []);
const esc = s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const ZW = /[​-‏⁠]/g; // zero-width joiners hide nothing
const strip = s => String(s == null ? '' : s).normalize('NFC').replace(ZW, '');
const norm = s => strip(s).toLowerCase();
// Boundary = anything that is not a letter or a number (works for every script, unlike \b).
const TERM_RE = new RegExp('(?<![\\p{L}\\p{N}])(?:' + ALL.map(t => esc(norm(t)).replace(/\s+/g, '\\s+')).join('|') + ')(?![\\p{L}\\p{N}])', 'u');
// Common gTLDs plus the ccTLDs link farms actually use. A short two-letter list keeps "Mr.Li" style text out of it.
const TLDS = 'com|net|org|info|biz|io|co|app|xyz|me|tv|us|uk|vn|de|fr|ru|in|id|br|es|it|nl|ca|au|eu|ch|at|be|pt|pl|cz|se|no|fi|dk|ie|nz|za|ng|ke|eg|tr|ua|il|ae|sa|pk|bd|lk|np|kh|la|mm|my|sg|ph|th|jp|kr|cn|tw|hk|mx|ar|cl|pe|to|ly|cc|gg|ai|pw|ws|tk|ml|ga|cf|gq|su|'
+ 'site|online|store|shop|club|top|pro|live|link|page|dev|fun|vip|one|tech|space|website|cloud|digital|agency|company|email|news|blog|life|world|today|zone|guru|ninja|game|games|team|network|money|cash|gold|bid|trade|win|bet|casino|poker|mobi|name|tel|travel|jobs|pics|photo|video|press|media|art|design|studio|capital|finance|exchange|solutions|services|systems|tools|works|center|group|global|international|institute|academy|school|education|university|church|community|social|chat|dating|love|wiki|review|reviews|directory|guide|help|support|rocks|ventures|holdings|partners|limited|ltd|llc|inc|asia|africa|london|nyc|tokyo|berlin|paris|best|buzz|click|host|hosting|lol|monster|wtf|ooo|icu|sbs|cfd|cyou|rest|bar|cam|surf|run|fit|health|care|dog|cat|pet|pets|wine|beer|vodka|bio|eco|green|energy|solar|car|cars|auto|bike|tires|taxi|limo|rent|rentals|house|homes|realty|estate|land|city|town|place|map|earth|fund|loans|credit|insure|legal|law|lawyer|attorney|tax|accountant|consulting|marketing|promo|sale|deals|discount|coupons|gift|gifts|toys|baby|kids|mom|family|wedding|party|events|tickets|show|theater|film|movie|music|band|dance|yoga|golf|football|soccer|hockey|tennis|racing';
// Schemes and www. are matched in any case; a bare domain token (or an email address) only with its TLD in lower case, so a
// missed space after a period ("ads.One day") is not mistaken for a link while real spam domains (typed lower case) are caught.
const SCHEME_RE = /(?:https?:\/\/|ftp:\/\/|(?<![\p{L}\p{N}])www\.)/iu;
const DOMAIN_RE = new RegExp('(?<![\\p{L}\\p{N}])[\\p{L}\\p{N}-]{1,63}(?:\\.[\\p{L}\\p{N}-]{1,63})*\\.(?:' + TLDS + ')(?![\\p{L}\\p{N}])', 'u');
// The matching prohibited term, or null.
function match(text) { const m = TERM_RE.exec(norm(text)); return m ? m[0].replace(/\s+/g, ' ') : null; }
// True when the text carries a URL or a domain-looking token (http(s)://, www., word.tld).
function hasUrl(text) { const t = strip(text); return SCHEME_RE.test(t) || DOMAIN_RE.test(t); }
const BIO_LINK_MSG = 'Links go in the social fields, not the bio.';
const blockedMsg = site => 'That content is not allowed on ' + (site || 'InstantAdPay/LinkSpin') + ' profiles (see Terms).';
const blockedAdMsg = site => 'That content is not allowed on ' + (site || 'InstantAdPay/LinkSpin') + ' (see Terms, Prohibited content).';
// Bio rule: no links, no prohibited terms. Returns { ok: true } or { error, reason }.
function checkBio(bio, site) {
const t = String(bio || '');
if (!t.trim()) return { ok: true };
if (hasUrl(t)) return { error: BIO_LINK_MSG, reason: 'url' };
const term = match(t);
if (term) return { error: blockedMsg(site), reason: 'term:' + term };
return { ok: true };
}
// Any other member-set text (social URL, banner target, campaign name, headline, copy): prohibited terms only.
// Pass profile: true for profile fields (the message names profiles), else the ad message is used.
function checkText(text, site, opts) {
const term = match(text);
if (!term) return { ok: true };
return { error: (opts && opts.profile) ? blockedMsg(site) : blockedAdMsg(site), reason: 'term:' + term };
}
// Several fields at once: { name: value, ... } -> first failure, with the field named in `field`.
function checkFields(fields, site, opts) {
for (const k of Object.keys(fields || {})) {
const v = fields[k]; if (v == null || v === '') continue;
const r = checkText(Array.isArray(v) ? v.join(' ') : String(v), site, opts);
if (r.error) return Object.assign({ field: k }, r);
}
return { ok: true };
}
// Profile ingest (registry sync from the other property, or a saved profile replayed): the parts of a profile that may be
// stored. A bio with a link or a prohibited term is dropped (null); a social URL carrying a prohibited term is dropped.
function cleanProfile(pf, site) {
const out = { avatarUrl: null, bio: null, socials: null, dropped: [] };
if (!pf || typeof pf !== 'object') return out;
const av = String(pf.avatarUrl || '').trim(); if (/^https:\/\/[^\s]+$/i.test(av) && av.length <= 300) out.avatarUrl = av;
const bio = String(pf.bio || '').trim().slice(0, 600);
if (bio) { const r = checkBio(bio, site); if (r.ok) out.bio = bio; else out.dropped.push('bio:' + r.reason); }
const src = pf.socials && typeof pf.socials === 'object' ? pf.socials : (typeof pf.socials === 'string' ? safeJson(pf.socials) : null);
if (src) {
const c = {};
for (const k of Object.keys(src)) {
const v = String(src[k] || '').trim(); if (!v) continue;
const r = checkText(v, site, { profile: true }); if (r.ok) c[k] = v; else out.dropped.push('socials.' + k + ':' + r.reason);
}
if (Object.keys(c).length) out.socials = c;
}
return out;
}
function safeJson(s) { try { const o = JSON.parse(s); return o && typeof o === 'object' ? o : null; } catch (e) { return null; } }
// Terms-page wording, one line per group (kept here so both sites say the same thing).
const POLICY = [
'gambling, casinos, betting, lotteries and sweepstakes',
'adult or sexual content',
'drugs and prescription pharmaceuticals',
'weapons',
'hate or harassment',
'malware, phishing and counterfeit goods',
'misleading financial promises',
'accounts created to place links in profile fields (link farming), which are removed without notice together with their profile text'
];
// One log line per refusal, with the email masked (never the text itself at full length).
function logRefusal(where, email, r) {
try { console.log('prohibited-content refused', where, String(email || '-').replace(/^(.).*(@.*)$/, '$1***$2'), r && r.field ? 'field=' + r.field : '', r && r.reason ? r.reason : ''); } catch (e) {}
}
module.exports = { LIST, ALL, POLICY, match, hasUrl, checkBio, checkText, checkFields, cleanProfile, logRefusal, BIO_LINK_MSG, blockedMsg, blockedAdMsg };
+7 -1
View File
@@ -293,6 +293,12 @@
<p class="small muted">Sponsor = the token the account joined under (username, share code, or member #). Editing it re-points free referrals and future purchases. On-chain sponsorship is permanent once activated.</p>
<div class="tablewrap"><table class="adm-table" id="memTable"></table></div>
</div>
<div class="card" id="spamCard">
<div class="card-head"><h3>Link-farm list</h3><span class="sub" id="spamSub">daily scan at 06:30 Central</span></div>
<p class="small muted">Free accounts (no package, no wallet) that carry a link plus a farm signal: a prohibited term in the profile, a sign-in that ended within 15 minutes of the sign-up, or no sponsor. Nothing is deleted on its own. Delete uses the normal member delete (on-chain members are refused) and never touches LinkSpin; the "also on LinkSpin" column is there so you can decide. Allow keeps an email off this list for good.</p>
<p style="display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin:0 0 10px"><button class="btn small" id="spamRun" type="button">Scan now</button><button class="btn small sec" id="spamDelete" type="button">Delete selected</button><span class="small muted" id="spamAllow"></span></p>
<div class="tablewrap"><table class="adm-table" id="spamTable"></table></div>
</div>
</div>
<div class="pane" id="pane-support" hidden>
@@ -645,6 +651,6 @@
<script src="/assets/common.js?v=20261023ov"></script><script src="/assets/welcome.js?v=20260923b"></script>
<script src="/assets/admin-kb.js?v=20261020kb"></script>
<script src="/assets/admin.js?v=20261029bx"></script><script src="/assets/admin-sponsorcheck.js?v=20261022sc"></script><script src="/assets/admin-kits.js?v=20261024kit"></script>
<script src="/assets/admin.js?v=20261030pp"></script><script src="/assets/admin-sponsorcheck.js?v=20261022sc"></script><script src="/assets/admin-kits.js?v=20261024kit"></script>
</body>
</html>
+27 -1
View File
@@ -306,6 +306,7 @@
} catch (e) {}
}
async function loadMembers() {
loadSpamScan().catch(() => {});
loadTank(); loadFraud();
const r = await api('/api/admin/members');
allMembers = r.members || [];
@@ -324,6 +325,31 @@
+ '<td class="act"><button class="btn small sec" data-mcopen="' + esc(a.email) + '">Open</button> <button class="btn small sec" data-susp="' + esc(a.email) + '" data-on="' + (a.suspended ? '1' : '0') + '">' + (a.suspended ? 'Unsuspend' : 'Suspend') + '</button> <button class="btn small sec" data-spon="' + esc(a.email) + '" data-cur="' + esc(a.sponsorRef || '') + '">Sponsor</button></td></tr>').join('');
}
$('memFilter').addEventListener('input', drawMembers);
// Link-farm list (2026-10-30): the daily scan's candidates; Delete selected = one DELETE /api/admin/member per email (on-chain refused); Allow = spamScanAllow
async function loadSpamScan() {
let v; try { v = await api('/api/admin/spamscan'); } catch (e) { return; }
const last = v.last || {}; const rows = last.candidates || [];
$('spamSub').textContent = last.at ? (rows.length + ' candidate' + (rows.length === 1 ? '' : 's') + ' \u00B7 scanned ' + when(last.at) + (last.manual ? ' (manual)' : '') + ' \u00B7 ' + (last.scanned || 0) + ' accounts, ' + (last.skipped || 0) + ' allowlisted') : 'no scan yet (daily at 06:30 Central)';
$('spamAllow').textContent = 'Allowlist: ' + ((v.allow || []).join(', ') || 'empty');
$('spamTable').innerHTML = '<tr><th></th><th>Account</th><th>Joined</th><th>Sponsor</th><th>First link</th><th>Why</th><th>Also on ' + esc(v.otherSite || 'the other site') + '</th><th></th></tr>'
+ (rows.length ? rows.map(c => '<tr><td><input type="checkbox" data-spamsel="' + esc(c.email) + '"></td><td>' + (c.username ? '<b>@' + esc(c.username) + '</b><br>' : '') + '<span class="small">' + esc(c.email) + '</span>' + (c.quarantined ? ' <span class="badge amber">quarantined</span>' : '') + '</td>'
+ '<td class="small muted when">' + when(c.created) + '</td><td class="small">' + esc(c.sponsorName || 'none') + '</td><td class="small mono" style="max-width:260px;overflow:hidden;text-overflow:ellipsis" title="' + esc((c.links || []).join(' ')) + '">' + esc(c.firstLink || '') + '</td>'
+ '<td class="small">' + esc((c.reasons || []).join(', ')) + '</td><td class="small">' + (c.alsoOn === true ? 'yes' : c.alsoOn === false ? 'no' : 'unknown') + '</td>'
+ '<td class="act"><button class="btn small sec" data-mcopen="' + esc(c.email) + '">Open</button> <button class="btn small sec" data-spamallow="' + esc(c.email) + '">Allow</button></td></tr>').join('') : '<tr><td colspan="8" class="muted small">Nothing to review.</td></tr>');
}
$('spamRun').addEventListener('click', busy($('spamRun'), async () => { await api('/api/admin/spamscan/run', {}); await loadSpamScan(); IAP.status('Scan done.', 'ok'); }));
$('spamDelete').addEventListener('click', busy($('spamDelete'), async () => {
const sel = [...document.querySelectorAll('[data-spamsel]:checked')].map(x => x.dataset.spamsel);
if (!sel.length) { IAP.status('Tick the accounts to delete first.', 'bad'); return; }
if (!await IAP.confirmBox('Delete ' + sel.length + ' account' + (sel.length === 1 ? '' : 's') + ' with their profile text? On-chain members are refused. LinkSpin is not touched.', { title: 'Delete selected', ok: 'Delete', cancel: 'Cancel' })) return;
let ok = 0, bad = 0; for (const e of sel) { try { await api('/api/admin/member?email=' + encodeURIComponent(e), undefined, 'DELETE'); ok++; } catch (err) { bad++; } }
IAP.status(ok + ' deleted' + (bad ? ', ' + bad + ' refused' : '') + '.', bad ? 'bad' : 'ok');
await api('/api/admin/spamscan/run', {}).catch(() => {}); await loadSpamScan(); loadMembers().catch(() => {});
}));
document.addEventListener('click', async e => {
const b = e.target.closest('[data-spamallow]'); if (!b) return;
try { await api('/api/admin/spamscan/allow', { email: b.dataset.spamallow }); IAP.status('Allowed ' + b.dataset.spamallow + '.', 'ok'); await api('/api/admin/spamscan/run', {}).catch(() => {}); loadSpamScan(); } catch (err) { IAP.status(err.message, 'bad'); }
});
document.addEventListener('click', async e => {
const b = e.target.closest('[data-susp]'); if (!b) return;
const on = b.dataset.on === '1';
@@ -404,7 +430,7 @@
mcCur = d; const a = d.account; $('memHits').hidden = true;
$('memCard').hidden = false; document.querySelectorAll('#pane-members > .card').forEach(c => { if (c.id !== 'memCard' && c.id !== 'memSearchCard') c.hidden = true; });
$('mcName').textContent = (a.username ? '@' + a.username : a.email) + (a.memberId ? ' · member #' + a.memberId : ' · free member');
$('mcSub').textContent = 'joined ' + when(a.created) + ' · last seen ' + ago(a.lastSeen);
$('mcSub').textContent = 'joined ' + when(a.created) + ' · last seen ' + ago(a.lastSeen) + (a.profileQuarantined ? ' · PROFILE QUARANTINED (link planted on a brand-new free account; not shown publicly)' : '');
$('mcWall').hidden = !a.username; if (a.username) $('mcWall').href = '/wall/' + a.username;
const ch = d.chain, cr = d.credits, t = d.totals;
const level = ch && !ch.readError ? (ch.buyerCount >= 5 ? 'level 3 (5+ buyers)' : ch.buyerCount >= 2 ? 'level 2 (2 buyers)' : 'level 1') : '';
+1 -1
View File
@@ -3464,7 +3464,7 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
for (const p of SOCIALS) body.socials[p] = ($('soc-' + p) && $('soc-' + p).value.trim()) || '';
if (pfAvatar) body.avatarUrl = pfAvatar;
const r = await api('/api/my/profile-details', body);
IAP.status('Profile saved.', 'ok');
IAP.status(r.notice ? 'Profile saved. ' + r.notice : 'Profile saved.', 'ok');
if (r.account) fillProfileDetails(r.account);
}));
$('lbUploadBtn').addEventListener('click', () => $('lbFile').click());
+8 -5
View File
@@ -17,9 +17,11 @@
title.innerHTML = safeName;
if (hostEl) hostEl.innerHTML = safeName;
IAP.$('bioHead').hidden = false;
if (w.avatarUrl) { const av = IAP.$('bioAvatar'); av.src = w.avatarUrl; av.hidden = false; }
// profile fields (avatar, bio, socials, intro video) are rendered only when the server says the member has bought (w.bought);
// a free member's wall shows the name, the line's ads and the join call, nothing from the profile (2026-10-30)
if (w.bought && w.avatarUrl) { const av = IAP.$('bioAvatar'); av.src = w.avatarUrl; av.hidden = false; }
if (w.badge) { const bb = IAP.$('bioBadge'); if (bb) { bb.src = w.badge.img; bb.title = w.badge.label + ' badge'; bb.hidden = false; } }
IAP.$('bioText').textContent = w.bio || 'Building a team on InstantAdPay — join through this page and you\'re in my line.';
IAP.$('bioText').textContent = (w.bought && w.bio) || 'Building a team on InstantAdPay. Join through this page and you are in my line.';
if (w.qrUrl) IAP.$('bioQr').src = w.qrUrl;
// social links
const SOC = { facebook: 'Facebook', twitter: 'X', youtube: 'YouTube', instagram: 'Instagram', tiktok: 'TikTok', telegram: 'Telegram', linkedin: 'LinkedIn', website: 'Website' };
@@ -36,14 +38,15 @@
website: svg('<circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3c3 3.5 3 14.5 0 18M12 3c-3 3.5-3 14.5 0 18"/>')
};
const sc = IAP.$('bioSocials');
if (sc && w.socials && typeof w.socials === 'object') {
if (sc && w.bought && w.socials && typeof w.socials === 'object') {
// paid placement: Google wants these marked sponsored (plus ugc), never a plain dofollow (2026-10-30)
const links = Object.keys(SOC).filter(k => w.socials[k]).map(k =>
'<a href="' + String(w.socials[k]).replace(/"/g, '%22') + '" target="_blank" rel="noopener nofollow me">' + (ICON[k] || '') + '<span>' + SOC[k] + '</span></a>');
'<a href="' + String(w.socials[k]).replace(/"/g, '%22') + '" target="_blank" rel="sponsored ugc noopener">' + (ICON[k] || '') + '<span>' + SOC[k] + '</span></a>');
sc.innerHTML = links.join('');
}
// intro video under the bio: YouTube / Vimeo embed, or a direct file
const bv = IAP.$('bioVideo');
const vurl = w.socials && typeof w.socials === 'object' ? String(w.socials.video || '') : '';
const vurl = w.bought && w.socials && typeof w.socials === 'object' ? String(w.socials.video || '') : '';
if (bv && vurl) {
let yt = /(?:youtube\.com\/(?:watch\?(?:.*&)?v=|shorts\/|embed\/)|youtu\.be\/)([A-Za-z0-9_-]{6,})/.exec(vurl);
let vm = /vimeo\.com\/(?:video\/)?(\d+)/.exec(vurl);
+3 -1
View File
@@ -110,6 +110,7 @@
<p><input id="obUsername" placeholder="Username (3-20 letters, numbers, _)" autocomplete="off" style="width:100%"></p>
<p class="muted small" style="margin:12px 0 4px">Optional — a short bio for your public page (you can skip this).</p>
<p><textarea id="obBio" rows="2" maxlength="600" placeholder="A short bio (optional)" style="width:100%"></textarea></p>
<p class="muted small" style="margin:-6px 0 8px">No links in the bio, and nothing from the prohibited list in the <a href="/terms#prohibited" target="_blank" rel="noopener">Terms</a>.</p>
<p id="obErr" class="small" style="color:var(--bad)" hidden></p>
<p style="margin-top:14px;display:flex;gap:10px;justify-content:flex-end">
<button class="btn sec small" id="obSkip" type="button" hidden>Skip for now</button>
@@ -1037,6 +1038,7 @@
<button class="btn small sec" id="pfAvatarBtn" type="button">Upload avatar</button>
<span class="small muted" id="pfAvatarInfo"></span></p>
<p><textarea id="pfBio" rows="3" maxlength="600" placeholder="A short bio for your profile page…" style="width:100%"></textarea></p>
<p class="small muted" style="margin:-6px 0 10px">No links in the bio, and nothing from the prohibited list in the <a href="/terms#prohibited" target="_blank" rel="noopener">Terms</a>.</p>
<p class="small muted" style="margin-bottom:4px">Social links (https URLs — shown on your public page):</p>
<div class="grid c2" style="gap:8px">
<input id="soc-facebook" placeholder="Facebook URL" style="width:100%">
@@ -1253,7 +1255,7 @@
<script src="/assets/wallet.js?v=20260911a"></script>
<script src="/assets/promo.js?v=20261029bx"></script>
<script src="/assets/support.js?v=20261016a"></script>
<script src="/assets/my.js?v=20261029bz"></script>
<script src="/assets/my.js?v=20261030pp"></script>
<script src="/assets/fuel.js?v=20261025ff"></script>
<script src="/assets/engine-room.js?v=20261025ff"></script>
<script src="/assets/chat.js?v=20261016n"></script>
+7 -4
View File
@@ -10,7 +10,7 @@
<body>
<div id="nav"></div>
<section><div class="wrap" style="max-width:820px">
<div class="sectionhead" style="text-align:left"><h2>Terms of Service</h2><p class="muted small">Last updated: September 2026</p></div>
<div class="sectionhead" style="text-align:left"><h2>Terms of Service</h2><p class="muted small">Last updated: October 2026</p></div>
<div class="card">
<p class="muted small">Please read these Terms carefully. By creating an account or using InstantAdPay ("the Platform"), you agree to them. If you do not agree, do not use the Platform.</p>
<h3>1. What InstantAdPay is</h3>
@@ -29,11 +29,14 @@
<p class="muted small">Ads you submit must be lawful and must not be deceptive, adult, hateful, malicious, or infringing. Ads are auto-approved for speed; we may remove or pause any ad or campaign at any time, and members can report ads for review. You are solely responsible for the ads you run and the sites they point to.</p>
<h3>7. Acceptable use</h3>
<p class="muted small">No fraud, bots, fake traffic, self-dealing to farm rewards, multiple or duplicate accounts, self-referral through another account, attempts to manipulate the contract, or abuse of other members. We may suspend or terminate accounts that break these rules.</p>
<h3>8. No warranty</h3>
<h3>8. Prohibited content</h3>
<div id="prohibited"></div>
<p class="muted small">The following may not appear anywhere on the Platform, in an ad, a campaign, a line banner, a wall offer, a bio or a social link: gambling, casinos, betting, lotteries and sweepstakes; adult or sexual content; drugs and prescription pharmaceuticals; weapons; hate or harassment; malware, phishing and counterfeit goods; misleading financial promises. Profile fields are not a place for links: a bio may not contain a URL or a domain, links belong in the social fields, and profile text, avatar and links are shown publicly only for members who have bought a package. Accounts created to place links in profile fields (link farming) are removed without notice, with their profile text. Content that matches these rules is refused when it is saved; what slips through is removed when found.</p>
<h3>9. No warranty</h3>
<p class="muted small">The Platform is provided "as is," without warranties of any kind. Blockchains, wallets, oracles, and third-party sites can fail or behave unexpectedly. We do not guarantee uptime, delivery volumes, or results.</p>
<h3>9. Limitation of liability</h3>
<h3>10. Limitation of liability</h3>
<p class="muted small">To the fullest extent permitted by law, InstantAdPay and its operators are not liable for indirect, incidental, or consequential damages, or for losses arising from crypto volatility, irreversible transactions, third-party sites, or your own decisions.</p>
<h3>10. Changes and termination</h3>
<h3>11. Changes and termination</h3>
<p class="muted small">We may update these Terms and the Platform, and continued use means you accept the changes. We may discontinue features. The immutable contract's rules cannot be changed by anyone, including us.</p>
<p class="muted small" style="margin-top:18px">See also the <a href="/disclaimer">Disclaimer</a> and <a href="/privacy">Privacy Policy</a>. Questions: the <a href="/support">support page</a> or <a href="mailto:support@instantadpay.com">support@instantadpay.com</a>.</p>
</div>
+1 -1
View File
@@ -48,6 +48,6 @@
</div>
</section>
<script src="/assets/common.js?v=20261023ov"></script><script src="/assets/welcome.js?v=20260923b"></script>
<script src="/assets/wall.js?v=20260911v"></script>
<script src="/assets/wall.js?v=20261030pp"></script>
</body>
</html>
+231
View File
@@ -0,0 +1,231 @@
// Profile policy + link-farm scan (2026-10-30 incident: 106 free accounts used bios and socials as casino backlinks).
// Same file in both repos (InstantAdPay site/qa and LinkSpin site/qa); it works out which site it is in.
// node qa/profile-policy.test.cjs (also part of `bash qa/run.sh member`)
// Part A, no server: prohibited.js (URL bio refused, casino bio refused, clean bio accepted, Unicode terms, no false hit on
// "Essex"), spamscan.classify on a six-account fixture (3 farm patterns, a sponsored member with a link, a buyer with a
// link, an allowlisted farm), the quarantine rule, the 06:30 once-a-day claim, the Telegram text, and the byte-for-byte
// check of prohibited.js + spamscan.js against the sibling checkout when it is there.
// Part B, a LOCAL copy (throwaway DATA_DIR, JSON store, devCode sign-in, the other site pointed at a dead port):
// a fresh sponsorless account's first save with a link is quarantined (200 + notice) and never rendered; a clean bio saves;
// then a URL bio and a casino bio are refused; a free member's wall and JSON carry nothing from the profile and the fixed
// description; a buyer's JSON carries bio + socials and the wall still has the fixed description; a deleted or unknown name
// is a real 404 with X-Robots-Tag noindex; the line banner refuses a casino target; the admin scan lists the quarantined
// account, Allow removes it; the admin member card shows the flag. Exit code 1 on any failure.
'use strict';
const fs = require('fs');
const os = require('os');
const path = require('path');
const http = require('http');
const crypto = require('crypto');
const { spawn } = require('child_process');
const ROOT = path.join(__dirname, '..');
const isLS = fs.existsSync(path.join(ROOT, 'iapsync.js'));
const SITE = isLS ? 'LinkSpin' : 'InstantAdPay';
const SIBLING = isLS ? path.join(ROOT, '..', '..', 'onchain-ad-membership', 'site') : path.join(ROOT, '..', '..', 'linkspin', 'site');
delete process.env.DATABASE_URL;
let fails = 0, n = 0;
async function t(name, fn) { n++; try { await fn(); console.log('ok', name); } catch (e) { fails++; console.log('FAIL', name, '::', e.message); } }
const eq = (a, b, m) => { if (a !== b) throw new Error((m || '') + ' expected ' + JSON.stringify(b) + ' got ' + JSON.stringify(a)); };
const truthy = (v, m) => { if (!v) throw new Error(m || 'expected truthy'); };
const P = require(path.join(ROOT, 'prohibited.js'));
const spamscan = require(path.join(ROOT, 'spamscan.js'));
(async () => {
// ---------------- Part A ----------------
await t('bio with a URL is refused with the bio-link message', () => {
for (const b of ['Visit https://casino-vip.com now', 'see www.example.com', 'my site example.com/offers', 'best deals at nice-shop.xyz', 'mail bob@gmail.com']) {
const r = P.checkBio(b, SITE); eq(r.error, 'Links go in the social fields, not the bio.', b);
}
});
await t('casino bio is refused with the Terms message', () => {
const r = P.checkBio('The best casino bonuses and slots in town', SITE);
eq(r.error, 'That content is not allowed on ' + SITE + ' profiles (see Terms).'); eq(r.reason, 'term:casino');
eq(P.checkBio('NỔ HŨ ĐỔI THƯỞNG uy tín', SITE).reason, 'term:nổ hũ', 'Vietnamese, upper case');
eq(P.checkBio('apostas online', SITE).reason, 'term:apostas');
eq(P.checkBio('we sell backlinks', SITE).reason, 'term:backlinks');
eq(P.checkBio('ca​sino', SITE).reason, 'term:casino', 'zero-width joiner stripped');
});
await t('clean bio is accepted; Essex, Sussex and sloppy punctuation are not links or terms', () => {
for (const b of ['Building a team on Polygon, paid the moment a package clears.', 'Essex marketer, Middlesex born, Sussex raised', 'I love ads.One day I will win', 'Price $9.99 v2.0 Oct.30 no.1', 'e.g. this, i.e. that', ''])
eq(P.checkBio(b, SITE).ok, true, b);
});
await t('campaign fields and social URLs: prohibited terms only, with the field named', () => {
const r = P.checkFields({ name: 'Spring push', title: 'Free slots tonight', targetUrl: 'https://example.com' }, SITE);
eq(r.field, 'title'); eq(r.error, 'That content is not allowed on ' + SITE + ' (see Terms, Prohibited content).');
eq(P.checkFields({ website: 'https://my-casino.bet/' }, SITE, { profile: true }).error, 'That content is not allowed on ' + SITE + ' profiles (see Terms).');
eq(P.checkFields({ name: 'Spring push', targetUrl: 'https://example.com/landing' }, SITE).ok, true);
});
await t('cleanProfile drops a linked or prohibited bio and a prohibited social, keeps the rest', () => {
const c = P.cleanProfile({ avatarUrl: 'https://img.example.com/a.png', bio: 'see casino.com', socials: { website: 'https://good.example.com/', twitter: 'https://x.com/slots_king' } }, SITE);
eq(c.bio, null); eq(c.avatarUrl, 'https://img.example.com/a.png'); eq(c.socials.website, 'https://good.example.com/'); eq(c.socials.twitter, undefined);
truthy(c.dropped.includes('bio:url') && c.dropped.some(d => d.startsWith('socials.twitter:term')), c.dropped.join(','));
});
// the fixture: who the detector must and must not flag
const DAY = 86400000, now = Date.now();
const F = [
{ email: 'farm1@x.test', username: 'farm1', memberId: 0, address: null, sponsorRef: 'someone', created: now - 3 * DAY, lastSeen: now - 3 * DAY + 60 * 60000, bio: 'Best casino bonuses', socials: JSON.stringify({ website: 'https://casino-x.com/' }) },
{ email: 'farm2@x.test', username: 'farm2', memberId: 0, address: null, sponsorRef: 'someone', created: now - 2 * DAY, lastSeen: now - 2 * DAY + 4 * 60000, bio: 'Local plumber in Austin', socials: JSON.stringify({ website: 'https://austin-plumber.example/' }) },
{ email: 'farm3@x.test', username: 'farm3', memberId: 0, address: null, sponsorRef: '', created: now - 1 * DAY, lastSeen: now - 1 * DAY + 3 * 60 * 60000, bio: 'Read my blog at huvip-blog.com', socials: null },
{ email: 'real@x.test', username: 'real', memberId: 0, address: null, sponsorRef: 'someone', created: now - 10 * DAY, lastSeen: now - 60000, bio: 'Team builder, here to learn', socials: JSON.stringify({ website: 'https://real-member.example/' }) },
{ email: 'buyer@x.test', username: 'buyer', memberId: 44, address: null, sponsorRef: '', created: now - 5 * DAY, lastSeen: now - 5 * DAY + 60000, bio: 'see my-site.com', socials: JSON.stringify({ website: 'https://my-site.com/' }) },
{ email: 'cryptogoat76@gmail.com', username: 'goat', memberId: 0, address: null, sponsorRef: '', created: now - 1 * DAY, lastSeen: now - 1 * DAY + 60000, bio: 'poker nights', socials: JSON.stringify({ website: 'https://poker.example/' }) },
];
await t('classify: three farm patterns flagged, sponsored member and buyer not, allowlisted skipped', () => {
const allow = new Set(spamscan.DEFAULT_ALLOW);
const v = Object.fromEntries(F.map(a => [a.username, spamscan.classify(a, allow, now)]));
truthy(v.farm1.candidate && v.farm1.reasons[0] === 'prohibited:casino', 'farm1 ' + v.farm1.reasons);
truthy(v.farm2.candidate && v.farm2.reasons.includes('quick'), 'farm2 ' + v.farm2.reasons);
truthy(v.farm3.candidate && v.farm3.reasons.includes('no-sponsor') && v.farm3.links[0] === 'huvip-blog.com', 'farm3 ' + v.farm3.reasons + ' ' + v.farm3.links);
eq(v.real.candidate, false, 'real member with a link'); eq(v.real.reasons.length, 0);
eq(v.buyer.candidate, false, 'buyer with a link');
eq(v.goat.candidate, false, 'allowlisted'); eq(v.goat.allowlisted, true);
eq(v.farm1.links[0], 'https://casino-x.com/');
});
await t('quarantine rule: brand-new, sponsorless, walletless, first save with a link', () => {
const fresh = { memberId: 0, address: null, sponsorRef: '', created: now - 3600000, bio: null, socials: null };
eq(spamscan.shouldQuarantine(fresh, 'see my-blog.com', null, now), true, 'bio url');
eq(spamscan.shouldQuarantine(fresh, 'hello', { website: 'https://my-blog.com/' }, now), true, 'website social');
eq(spamscan.shouldQuarantine(fresh, 'hello', { twitter: 'https://x.com/me' }, now), true, 'X social');
eq(spamscan.shouldQuarantine(fresh, 'hello', { telegram: 'https://t.me/me' }, now), false, 'telegram is not a farm field');
eq(spamscan.shouldQuarantine(fresh, 'hello world', null, now), false, 'no link');
eq(spamscan.shouldQuarantine(Object.assign({}, fresh, { sponsorRef: 'marty' }), 'see my-blog.com', null, now), false, 'has a sponsor');
eq(spamscan.shouldQuarantine(Object.assign({}, fresh, { created: now - 25 * 3600000 }), 'see my-blog.com', null, now), false, 'older than 24 h');
eq(spamscan.shouldQuarantine(Object.assign({}, fresh, { bio: 'old bio' }), 'see my-blog.com', null, now), false, 'not the first save');
eq(spamscan.shouldQuarantine(Object.assign({}, fresh, { address: '0xabc' }), 'see my-blog.com', null, now), false, 'has a wallet');
eq(spamscan.shouldQuarantine(Object.assign({}, fresh, { memberId: 3 }), 'see my-blog.com', null, now), false, 'bought');
});
function bench(o) {
o = o || {}; const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'spamscan-'));
const sent = []; const site = { spamScanAllow: spamscan.DEFAULT_ALLOW.join(', ') }; const claims = o.claims || new Set();
spamscan.init({ dataDir: dir, site: SITE, siteUrl: 'https://' + SITE.toLowerCase() + '.test', otherSite: isLS ? 'InstantAdPay' : 'LinkSpin',
accounts: { listAll: async () => o.accounts || F }, siteConfig: () => site, saveSite: p => Object.assign(site, p), notify: async text => { sent.push(text); },
marks: { claim: async k => { if (o.claimFalse) return false; if (claims.has(k)) return false; claims.add(k); return true; } }, alsoOn: async e => e === 'farm1@x.test' ? true : false });
return { dir, sent, site, claims };
}
const at = (h, m) => { // a timestamp on today's Central date at h:m Central
const d = new Date(); const ct = new Date(d.toLocaleString('en-US', { timeZone: 'America/Chicago' })); const diff = d.getTime() - ct.getTime();
ct.setHours(h, m, 0, 0); return ct.getTime() + diff;
};
await t('tick: nothing before 06:30, one run from 06:30 on, never twice in a day, result file written, one Telegram with the site name', async () => {
const b = bench();
let r = await spamscan.tick(at(6, 0)); eq(r.skipped, true, 'before 06:30'); eq(b.sent.length, 0);
r = await spamscan.tick(at(6, 31)); truthy(r.candidates, 'ran'); eq(r.candidates.length, 3, 'three candidates'); eq(r.skipped, 1, 'one allowlisted');
eq(b.sent.length, 1, 'one telegram'); truthy(b.sent[0].startsWith(SITE + ' link-farm scan: 3 candidate accounts ('), b.sent[0].split('\n')[0]);
truthy(b.sent[0].includes('Review in Admin > Members > Link-farm list'), 'review line'); truthy(b.sent[0].includes('@farm1 | joined ') && b.sent[0].includes('| https://casino-x.com/ | also on ' + (isLS ? 'InstantAdPay' : 'LinkSpin')), b.sent[0]);
r = await spamscan.tick(at(9, 0)); eq(r.skipped, true, 'second tick same day'); eq(b.sent.length, 1, 'still one telegram');
const file = JSON.parse(fs.readFileSync(path.join(b.dir, 'wall-spam-scan.json'), 'utf8'));
eq(file.candidates.length, 3); eq(file.candidates.find(c => c.email === 'farm1@x.test').alsoOn, true); eq(file.scanned, 6);
truthy(b.claims.has('spamscan:' + spamscan.dayOf(at(6, 31))), 'claim key is the Central day');
});
await t('tick: a second app copy that loses the claim does not run or notify', async () => {
const b = bench({ claimFalse: true });
const r = await spamscan.tick(at(7, 0)); eq(r.skipped, true); eq(r.claimedElsewhere, true); eq(b.sent.length, 0);
});
await t('run: no candidates means no Telegram; Allow removes a candidate on the next run', async () => {
const b = bench({ accounts: F.filter(a => a.username === 'real' || a.username === 'buyer') });
const r = await spamscan.run(); eq(r.candidates.length, 0); eq(b.sent.length, 0);
const b2 = bench(); await spamscan.run(); eq(spamscan.view().last.candidates.length, 3);
spamscan.setAllow('farm2@x.test', true); truthy(spamscan.allowlist().includes('farm2@x.test')); truthy(b2.site.spamScanAllow.includes('farm2@x.test'), 'saved to the site setting');
await spamscan.run({ quiet: true }); eq(spamscan.view().last.candidates.length, 2); eq(spamscan.view().last.skipped, 2);
spamscan.setAllow('farm2@x.test', false); eq(spamscan.allowlist().includes('farm2@x.test'), false);
});
await t('shared modules are byte-for-byte copies of the sibling checkout (prohibited.js, spamscan.js)', () => {
if (!fs.existsSync(SIBLING)) { console.log(' (sibling checkout not found at ' + SIBLING + ', skipped)'); return; }
for (const f of ['prohibited.js', 'spamscan.js', path.join('qa', 'profile-policy.test.cjs')]) {
const h = p => crypto.createHash('sha1').update(fs.readFileSync(p, 'utf8').replace(/\r\n/g, '\n')).digest('hex');
const a = path.join(ROOT, f), b = path.join(SIBLING, f);
if (!fs.existsSync(b)) throw new Error(f + ' missing in sibling');
eq(h(a), h(b), f + ' differs from the sibling copy');
}
});
// ---------------- Part B ----------------
const PORT = Number(process.env.PP_PORT || (isLS ? 8807 : 8806)); const ADMIN = 'localtest';
const DATA = fs.mkdtempSync(path.join(os.tmpdir(), 'pp-' + SITE.toLowerCase() + '-')); fs.mkdirSync(path.join(DATA, 'uploads'), { recursive: true });
// a paying member, seeded straight into the JSON store (memberId > 0): profile must render for them
const seed = { v: 2, byEmail: {}, byAddress: {}, byCode: {}, positions: {}, joins: 0 };
seed.byEmail['buyer@example.com'] = { email: 'buyer@example.com', code: 'buyr01', username: 'buyerwall', memberId: 7, sponsorRef: '', created: now - 30 * DAY, lastSeen: now - DAY,
bio: 'Clean bio from a paying member', socials: JSON.stringify({ website: 'https://example.com/', twitter: 'https://x.com/buyer' }), avatarUrl: 'https://example.com/a.png' };
seed.byCode.buyr01 = 'buyer@example.com';
fs.writeFileSync(path.join(DATA, 'accounts.json'), JSON.stringify(seed));
const env = Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: DATA, NODE_ENV: 'development', ADMIN_EMAIL: 'qa-admin@example.com', ADMIN_PASSWORD: ADMIN,
LS_URL: 'http://127.0.0.1:1', IAP_URL: 'http://127.0.0.1:1', LS_SYNC_SECRET: '' });
delete env.DATABASE_URL;
const srv = spawn(process.execPath, ['server.js'], { cwd: ROOT, env, stdio: ['ignore', 'pipe', 'pipe'] });
let log = ''; srv.stdout.on('data', d => { log += d; }); srv.stderr.on('data', d => { log += d; });
const req = (method, p, o) => new Promise((resolve, reject) => { o = o || {};
const headers = Object.assign({ 'User-Agent': 'Mozilla/5.0 QA', 'X-Forwarded-For': o.ip || '10.9.0.1' }, o.headers || {}); if (o.cookie) headers.Cookie = o.cookie;
let body = o.body; if (body) { body = Buffer.from(JSON.stringify(body)); headers['Content-Type'] = 'application/json'; headers['Content-Length'] = body.length; }
const r = http.request({ host: '127.0.0.1', port: PORT, path: p, method, headers }, res => { const ch = []; res.on('data', c => ch.push(c)); res.on('end', () => { const text = Buffer.concat(ch).toString(); let json = null; try { json = JSON.parse(text); } catch (e) {} resolve({ status: res.statusCode, headers: res.headers, text, json }); }); });
r.on('error', reject); if (body) r.write(body); r.end(); });
const adminH = { Authorization: 'Bearer ' + ADMIN };
let ipn = 1;
async function signIn(email) {
const ip = '10.9.' + (ipn++) + '.7';
const s = await req('POST', '/api/auth/email/start', { ip, body: { email, fts: Date.now() - 8000, fage: 8000, hp_field_x9: '' } });
if (!s.json || !s.json.devCode) throw new Error('no devCode for ' + email + ': ' + s.text.slice(0, 200));
const v = await req('POST', '/api/auth/email/verify', { ip, body: { email, code: s.json.devCode } });
return [].concat(v.headers['set-cookie'] || []).map(x => x.split(';')[0]).join('; ');
}
const meta = (html, name) => { const m = new RegExp('<meta (?:name|property)="' + name + '" content="([^"]*)"').exec(html); return m ? m[1] : null; };
try {
let up = false; for (let i = 0; i < 60 && !up; i++) { try { up = (await req('GET', '/api/config')).status === 200; } catch (e) { await new Promise(r => setTimeout(r, 500)); } }
if (!up) throw new Error('local server did not come up:\n' + log.slice(-1500));
await req('PATCH', '/api/admin/site', { headers: adminH, body: { fraudMaxSignupsPerIpDay: 20 } });
const fixed = nm => nm + '’s ad wall on ' + SITE + ': the network’s member ads, paid out on Polygon the moment a package clears.';
await t('local: unknown or deleted wall name is a real 404 with X-Robots-Tag noindex', async () => {
const r = await req('GET', '/wall/huvipblog'); eq(r.status, 404); truthy(/noindex/.test(String(r.headers['x-robots-tag'])), 'x-robots-tag ' + r.headers['x-robots-tag']);
truthy(r.text.includes('No wall under that name'), 'body'); eq((await req('GET', '/api/wall/huvipblog')).status, 404);
});
await t('local: fresh sponsorless account, first save with a link: quarantined, saved, notice, nothing public', async () => {
const ck = await signIn('fresh@example.com');
eq((await req('POST', '/api/my/profile', { cookie: ck, body: { username: 'freshlink' } })).status, 200);
const r = await req('POST', '/api/my/profile-details', { cookie: ck, body: { bio: 'Read my blog at huvip-blog.com', socials: { website: 'https://huvip-blog.com/' } } });
eq(r.status, 200, r.text); eq(r.json.quarantined, true); eq(r.json.notice, 'Your profile links will appear after your first ad package.'); eq(r.json.account.profileQuarantined, true);
const w = await req('GET', '/api/wall/freshlink'); eq(w.status, 200); eq(w.json.bought, false); eq(w.json.bio, null); eq(w.json.socials, null); eq(w.json.avatarUrl, null);
const h = await req('GET', '/wall/freshlink'); eq(h.status, 200); eq(meta(h.text, 'description'), fixed('@freshlink')); eq(meta(h.text, 'og:description'), fixed('@freshlink'));
truthy(!h.text.includes('huvip-blog'), 'bio text must not be in the page'); truthy(!/noindex/i.test(h.text) && !r.headers['x-robots-tag'], 'wall stays indexable');
const m = await req('GET', '/api/admin/member?email=fresh@example.com', { headers: adminH }); eq(m.json.account.profileQuarantined, true, 'admin card flag');
});
await t('local: clean bio saves; then a URL bio and a casino bio are refused; a casino social is refused', async () => {
const ck = await signIn('clean@example.com');
await req('POST', '/api/my/profile', { cookie: ck, body: { username: 'cleanmember' } });
let r = await req('POST', '/api/my/profile-details', { cookie: ck, body: { bio: 'Team builder on Polygon, paid when a package clears.' } }); eq(r.status, 200, r.text); eq(r.json.quarantined, undefined);
r = await req('POST', '/api/my/profile-details', { cookie: ck, body: { bio: 'Visit https://my-shop.example.com for deals' } }); eq(r.status, 400); eq(r.json.error, 'Links go in the social fields, not the bio.');
r = await req('POST', '/api/my/profile-details', { cookie: ck, body: { bio: 'Best casino bonuses and slots' } }); eq(r.status, 400); eq(r.json.error, 'That content is not allowed on ' + SITE + ' profiles (see Terms).');
r = await req('POST', '/api/my/profile-details', { cookie: ck, body: { socials: { website: 'https://top-casino.bet/' } } }); eq(r.status, 400); eq(r.json.error, 'That content is not allowed on ' + SITE + ' profiles (see Terms).');
const w = await req('GET', '/api/wall/cleanmember'); eq(w.json.bought, false); eq(w.json.bio, null, 'free member: no bio on the public JSON');
const h = await req('GET', '/wall/cleanmember'); eq(h.status, 200); eq(meta(h.text, 'description'), fixed('@cleanmember')); truthy(!h.text.includes('Team builder on Polygon'), 'free member: no bio in the page');
r = await req('POST', '/api/my/linebanner', { cookie: ck, body: { targetUrl: 'https://casino-royale.example/' } }); eq(r.status, 400); truthy(/not allowed/.test(r.json.error), r.json.error);
});
await t('local: a paying member gets bio, socials and avatar in the JSON; the wall keeps the fixed description and title carries the handle', async () => {
const w = await req('GET', '/api/wall/buyerwall'); eq(w.status, 200, w.text); eq(w.json.bought, true); eq(w.json.bio, 'Clean bio from a paying member'); eq(w.json.socials.website, 'https://example.com/'); eq(w.json.avatarUrl, 'https://example.com/a.png');
const h = await req('GET', '/wall/buyerwall'); eq(h.status, 200); eq(meta(h.text, 'description'), fixed('@buyerwall')); eq(meta(h.text, 'og:image'), 'https://example.com/a.png');
truthy(/<title>@buyerwall’s ad wall \| /.test(h.text), 'title'); truthy(!h.text.includes('Clean bio from a paying member'), 'bio never in the meta');
const js = fs.readFileSync(path.join(ROOT, 'public', 'assets', 'wall.js'), 'utf8');
truthy(js.includes('rel="sponsored ugc noopener"') && !js.includes('rel="noopener nofollow me"'), 'outbound profile links are sponsored ugc');
truthy(/w\.bought && w\.socials/.test(js) && /\(w\.bought && w\.bio\)/.test(js), 'wall.js renders profile only when bought');
truthy(fs.readFileSync(path.join(ROOT, 'public', 'wall.html'), 'utf8').includes('wall.js?v=20261030pp'), 'wall.js version bumped');
});
await t('local: admin scan lists the quarantined account, not the buyer or the clean member; Allow removes it', async () => {
let r = await req('POST', '/api/admin/spamscan/run', { headers: adminH, body: {} }); eq(r.status, 200, r.text);
const emails = r.json.last.candidates.map(c => c.email); truthy(emails.includes('fresh@example.com'), emails.join(',')); truthy(!emails.includes('buyer@example.com') && !emails.includes('clean@example.com'), emails.join(','));
const c = r.json.last.candidates.find(x => x.email === 'fresh@example.com'); truthy(c.reasons.includes('quarantined') && c.reasons.includes('no-sponsor'), c.reasons.join(',')); eq(c.firstLink, 'https://huvip-blog.com/'); truthy('alsoOn' in c, 'also-on column present');
truthy(fs.existsSync(path.join(DATA, 'wall-spam-scan.json')), 'result file');
r = await req('POST', '/api/admin/spamscan/allow', { headers: adminH, body: { email: 'fresh@example.com' } }); truthy(r.json.allow.includes('fresh@example.com'));
r = await req('POST', '/api/admin/spamscan/run', { headers: adminH, body: {} }); truthy(!r.json.last.candidates.some(x => x.email === 'fresh@example.com'), 'allowed account gone');
r = await req('POST', '/api/admin/spamscan/allow', { headers: adminH, body: { email: 'fresh@example.com', remove: true } }); truthy(!r.json.allow.includes('fresh@example.com'));
r = await req('DELETE', '/api/admin/member?email=fresh@example.com', { headers: adminH }); eq(r.status, 200, r.text);
eq((await req('GET', '/wall/freshlink')).status, 404, 'deleted wall is a 404');
eq((await req('DELETE', '/api/admin/member?email=buyer@example.com', { headers: adminH })).status, 400, 'on-chain member refused');
});
} catch (e) { fails++; console.log('FAIL local copy ::', e.message); }
finally { try { srv.kill(); } catch (e) {} await new Promise(r => setTimeout(r, 300)); try { fs.rmSync(DATA, { recursive: true, force: true }); } catch (e) {} }
if (fails && /error|Error/.test(log)) console.log('--- server log tail ---\n' + log.slice(-2500));
console.log(fails ? fails + ' of ' + n + ' checks FAILED' : 'profile policy + link-farm scan: all ' + n + ' checks passed');
process.exit(fails ? 1 : 0);
})();
+4
View File
@@ -17,6 +17,7 @@
# bash qa/run.sh override # level-4 override: week math, hunt, house, dust carry, cap, balance, two concurrent payers (fake chain + signer, throwaway data)
# bash qa/run.sh convpixel # conversion pixel: lsclk click ids on /api/ads/click, signed push to a MOCK LinkSpin, own-click self flag, Campaigns > Conversion tracking + cost per goal, LinkSpin down (local copy, throwaway data)
# bash qa/run.sh fuel # Fuel Your Offers: refill notices, refuel streak, Refuel Kit, Engine Room (unit + two-copy tests, throwaway data)
# bash qa/run.sh policy # profile policy + link-farm scan: prohibited list, bio links, quarantine, 06:30 claim, walls of free/paying members, 404 walls (unit + local copy; also runs in member)
# bash qa/run.sh bixpay # BixPay card: partner-link validator, sponsor-follows resolver (own / level 3 / company), gate, click store (unit, no server; also runs in member)
# Each local run boots server.js on its own port with a throwaway data dir (JSON store, no DB, no
# mail key, devCode sign-in), so nothing touches production data. Reports land in qa/out/.
@@ -60,6 +61,9 @@ elif [ "$MODE" = "member" ]; then
node qa/tank-hold.mjs || status=1
node qa/walletnudge.test.cjs || status=1
node qa/bixpay.test.cjs || status=1
node qa/profile-policy.test.cjs || status=1
elif [ "$MODE" = "policy" ]; then
node qa/profile-policy.test.cjs || status=1
elif [ "$MODE" = "bixpay" ]; then
node qa/bixpay.test.cjs || status=1
elif [ "$MODE" = "walletnudge" ]; then
+59 -12
View File
@@ -70,7 +70,9 @@ const audit = require('./audit'); // counter audit: views vs delivery logs,
const leaderboard = require('./leaderboard');
const toolkit = require('./toolkit');
const badge = require('./badge'); // achievement badge image drawn on the server with ffmpeg (2026-09-16)
const friday = require('./friday');
const friday = require('./friday');
const prohibited = require('./prohibited'); // prohibited-content policy shared with LinkSpin (2026-10-30 link-farm incident)
const spamscan = require('./spamscan'); // daily link-farm scan + quarantine rule, byte-for-byte copy on LinkSpin
const starter = require('./starter'); // member welcome offer from the games (2026-10-05)
const wednesday = require('./wednesday'); // Wired Wednesday: +25% on $10+ packs, wired into a visits campaign (2026-09-29)
const fridaybank = require('./fridaybank'); // Friday Bonus Hunts: days banked Sat-Thu by solo + video (2026-09-26)
@@ -168,6 +170,14 @@ const videoTokens = persistedMap('video'); // email -> watch-to-earn video token
const faucetHits = new Map(); // address -> last faucet ts (rehearsal test-POL faucet rate limit)
const visitTokens = persistedMap('visit'); // email -> verified-visit token (dwell + captcha floor)
// walk the referral chain upward via sponsorRef (code/username/member id)
// A PAYING member (memberId > 0, or a registered linked position) gets their profile on public pages; a free account gets
// nothing from the profile there (2026-10-30 link-farm incident: 106 free accounts used bios and socials as backlinks).
async function hasBought(a) {
if (!a) return false; if (Number(a.memberId) > 0) return true;
try { return (await accounts.positions(a.email)).some(p => Number(p.memberId) > 0); } catch (e) { return false; }
}
// the wall's meta description is always this sentence, never profile text, so the indexed snippet is ours
const wallDescription = nm => nm + '\u2019s ad wall on InstantAdPay: the network\u2019s member ads, paid out on Polygon the moment a package clears.';
async function uplineSlides(email, depth = 3) {
const out = [];
let cur = await accounts.byEmail(email);
@@ -614,7 +624,14 @@ async function boot() {
setInterval(() => refuel.tick().catch(e => console.error('refuel', e.message)), 10 * 60 * 1000);
setTimeout(() => refill.tick().catch(e => console.error('refill', e.message)), 90000);
setInterval(() => refill.tick().catch(e => console.error('refill', e.message)), 20 * 60 * 1000);
setInterval(() => friday.tick().catch(e => console.error('friday', e.message)), 5 * 60 * 1000);
setInterval(() => friday.tick().catch(e => console.error('friday', e.message)), 5 * 60 * 1000);
// link-farm scan (2026-10-30): 06:30 Central, once a day across app copies (marks), Telegram to the private admin chat only when there is something to review
spamscan.init({ dataDir: DATA_DIR, site: 'InstantAdPay', siteUrl: 'https://instantadpay.com', otherSite: 'LinkSpin', accounts, siteConfig, marks,
saveSite: patch => { const cur = siteConfig(); fs.writeFileSync(SITE_FILE, JSON.stringify(Object.assign(cur, patch), null, 2)); },
notify: async text => { const sc = siteConfig(); const chat = String(sc.telegramAdminChatId || '1289244227').trim(); if (sc.telegramBotToken) return telegramSend(chat, text); const hermes = String(process.env.HERMES_BOT_TOKEN || '').trim(); if (hermes) return tgSendAs(hermes, chat, text); if (ADMIN_EMAIL && mailer.hasKey()) return mailer.send(ADMIN_EMAIL, 'InstantAdPay link-farm scan', text); },
alsoOn: async (email, a) => (a && a.joinedVia === 'linkspin') ? true : lssync.knows(email) });
setTimeout(() => spamscan.tick().catch(e => console.error('spamscan', e.message)), 150000);
setInterval(() => spamscan.tick().catch(e => console.error('spamscan', e.message)), 5 * 60 * 1000);
wednesday.init({ dataDir: DATA_DIR, siteConfig, chain, ads, accounts, mailer, drip, marks, rates: () => ads.rates(),
telegram: async text => { const sc = siteConfig(); if (!sc.telegramBotToken || !sc.telegramEchoChatId) return false; return telegramSend(sc.telegramEchoChatId, '\u{1F7E0} <b>InstantAdPay</b> · ' + text, sc.telegramEchoTopicId); },
notify: async (memberId, subject, text, kind) => { const a = await accounts.byMemberId(memberId); if (!a || !a.email) return; const html = '<p>' + String(text).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/(https:\/\/[^\s]+)/g, '<a href="$1" target="_blank" rel="noopener">$1</a>').split('\n\n').join('</p><p>').replace(/\n/g, '<br>') + '</p>'; await messages.deliver(1, ADMIN_EMAIL || 'house@instantadpay.com', [a.email], subject, html, kind || 'notice'); } });
@@ -781,7 +798,8 @@ function siteConfig() {
telegramBotToken: '', telegramChatId: '', telegramTopicId: '', telegramEvents: 'payouts', telegramCtaUrl: 'https://instantadpay.com/',
fraudMaxSignupsPerIpDay: 2, fraudBlockSharedDevice: 'on', // anti-fraud: accounts per IP per day; block a second account from the same browser
telegramEchoChatId: '', telegramEchoTopicId: '', telegramEchoEvents: 'payouts', // shared cross-program payments topic
telegramAdminChatId: '', // private chat for admin alerts (sign-up guard bursts); falls back to ADMIN_EMAIL
telegramAdminChatId: '', // private chat for admin alerts (sign-up guard bursts); falls back to ADMIN_EMAIL
spamScanAllow: spamscan.DEFAULT_ALLOW.join(', '), // link-farm scan (2026-10-30): emails never listed as candidates; Admin > Members > Link-farm list > Allow adds here
fridayPromo: '1', // Five Dollar Friday on/off (Marty, 2026-09-20)
fridayBonusPct: '20', // bonus credits on any $5+ package bought on a Friday, Central
fridayStart: '2026-09-25', // the first Five Dollar Friday
@@ -2388,7 +2406,7 @@ const server = http.createServer(async (req, res) => {
const t = nameTok.toLowerCase();
let a = await accounts.byCode(t); if (!a) a = await accounts.byUsername(t);
if (!a && /^\d+$/.test(nameTok)) a = await accounts.byMemberId(Number(nameTok));
if (a) { name = a.username ? '@' + a.username : (a.memberId ? 'member #' + a.memberId : null); avatarUrl = a.avatarUrl || null; own = !!(acct && a.email === acct.email); var bio = null, cobrand = false; try { cobrand = (await ads.milestonesOf(a.email)).includes('level3'); if (cobrand) bio = a.bio ? String(a.bio).slice(0, 220) : null; } catch (e) {} }
if (a) { name = a.username ? '@' + a.username : (a.memberId ? 'member #' + a.memberId : null); avatarUrl = a.avatarUrl || null; own = !!(acct && a.email === acct.email); var bio = null, cobrand = false; try { cobrand = (await ads.milestonesOf(a.email)).includes('level3'); if (cobrand && !a.profileQuarantined && await hasBought(a)) bio = a.bio ? String(a.bio).slice(0, 220) : null; } catch (e) {} }
}
// "You're joining the line of X" must only greet someone who is actually about to
// join. The last-touch sponsor cookie lives 30 days, so an EXISTING member who once
@@ -3021,6 +3039,15 @@ const server = http.createServer(async (req, res) => {
}
return json(res, 200, await adminMember.view(e));
}
// -- link-farm scan (2026-10-30): last result + allowlist, run now (no Telegram), allow / unallow an email
if (p === '/api/admin/spamscan' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, spamscan.view()); }
if (p === '/api/admin/spamscan/run' && req.method === 'POST') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); await spamscan.run({ manual: true, quiet: true }); return json(res, 200, spamscan.view()); }
if (p === '/api/admin/spamscan/allow' && req.method === 'POST') {
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
const b = await readBody(req); const e = String(b.email || '').trim().toLowerCase(); if (!e) return json(res, 400, { error: 'Which email?' });
spamscan.setAllow(e, !b.remove); console.log('spamscan allowlist', b.remove ? 'removed' : 'added', e);
return json(res, 200, spamscan.view());
}
if (p === '/api/admin/member' && req.method === 'DELETE') {
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
const e = String(u.searchParams.get('email') || '').trim().toLowerCase(); const acct = e && await accounts.byEmail(e);
@@ -4638,7 +4665,7 @@ const server = http.createServer(async (req, res) => {
return json(res, 400, { error: 'Avatar must be an uploaded image or an https image URL.' });
const bio = b.bio === undefined ? undefined : String(b.bio || '').trim().slice(0, 600);
// socials: {platform: url}; keep only known platforms with valid https urls
let socials;
let socials, cleanSoc = null;
if (b.socials !== undefined) {
const PLAT = ['facebook', 'twitter', 'youtube', 'instagram', 'tiktok', 'telegram', 'linkedin', 'website', 'video'];
const clean = {};
@@ -4650,8 +4677,17 @@ const server = http.createServer(async (req, res) => {
if (clean.video && !/^https:\/\/((www\.|m\.)?youtube\.com\/(watch\?|shorts\/|embed\/)|youtu\.be\/|(www\.)?vimeo\.com\/\d+|player\.vimeo\.com\/video\/\d+|[^\s]+\.(mp4|webm)(\?|$))/i.test(clean.video))
return json(res, 400, { error: 'The intro video needs to be a YouTube link, a Vimeo link, or a direct .mp4 link.' });
socials = Object.keys(clean).length ? JSON.stringify(clean) : null;
cleanSoc = clean;
}
const r = await accounts.setProfile(s.email, avatar, bio, socials);
// prohibited-content policy (2026-10-30): gambling, adult, pharma, weapons and link-selling terms are refused in the bio and the social URLs
{ const pr = prohibited.checkFields(Object.assign({ bio }, cleanSoc || {}), 'InstantAdPay', { profile: true }); if (pr.error) { prohibited.logRefusal('profile-details', s.email, pr); return json(res, 400, { error: pr.error }); } }
// a bio is not a backlink: links go in the social fields. Exception, the quarantine rule: a brand-new free account (no wallet,
// no sponsor, under 24 h) whose first save plants a link is saved with profileQuarantined and never rendered publicly
const acct = await accounts.byEmail(s.email);
const quarantine = spamscan.shouldQuarantine(acct, bio, cleanSoc) ? true : undefined;
if (bio && prohibited.hasUrl(bio) && !quarantine) { prohibited.logRefusal('profile-details', s.email, { field: 'bio', reason: 'url' }); return json(res, 400, { error: prohibited.BIO_LINK_MSG }); }
const r = await accounts.setProfile(s.email, avatar, bio, socials, quarantine);
if (quarantine && !r.error) { console.log('profile quarantined', String(s.email).replace(/^(.).*(@.*)$/, '$1***$2'), prohibited.hasUrl(bio) ? 'bio-url' : 'social-link'); r.quarantined = true; r.notice = spamscan.QUARANTINE_NOTICE; }
return json(res, r.error ? 400 : 200, r);
}
// -- BixPay partner link (2026-10-29): Profile > BixPay card. Validated (bix.ibportal.io/auth/register, e=, a=1; the
@@ -4693,6 +4729,7 @@ const server = http.createServer(async (req, res) => {
const title = String(o.title || '').trim().slice(0, 60);
if (targetUrl && !/^https:\/\/[^\s]+$/i.test(targetUrl)) return json(res, 400, { error: 'Position ' + (i + 2) + ': the link must start with https://' });
if (bannerUrl && !/^(\/uploads\/[a-z0-9]{24}\.(png|jpg|webp|gif)|https:\/\/[^\s]+)$/i.test(bannerUrl)) return json(res, 400, { error: 'Position ' + (i + 2) + ': banner must be an uploaded image or an https image URL.' });
{ const pr = prohibited.checkFields({ title, targetUrl }, 'InstantAdPay'); if (pr.error) { prohibited.logRefusal('wall-offers', s.email, pr); return json(res, 400, { error: pr.error }); } }
out.push(targetUrl ? { title: title || null, bannerUrl: bannerUrl || null, targetUrl } : null);
}
const r = await accounts.setWallOffers(s.email, out.some(Boolean) ? JSON.stringify(out) : null);
@@ -4705,6 +4742,7 @@ const server = http.createServer(async (req, res) => {
const b = await readBody(req);
const target = String(b.targetUrl || '').trim();
if (!/^https?:\/\/[^\s]+$/i.test(target)) return json(res, 400, { error: 'Destination URL must start with http(s)://' });
{ const pr = prohibited.checkFields({ targetUrl: target }, 'InstantAdPay'); if (pr.error) { prohibited.logRefusal('linebanner', s.email, pr); return json(res, 400, { error: pr.error }); } }
const fc = await frameCheck(target); // welcome tours frame it full screen
if (!fc.ok) return json(res, 400, { error: fc.reason });
const banner = String(b.bannerUrl || '').trim();
@@ -4770,9 +4808,11 @@ const server = http.createServer(async (req, res) => {
badge = { img: '/badges/badge-' + t[0] + '.jpg?v=2', label: t[1] };
}
const joinPath = '/join/' + (a.username || a.code);
let socials = null; try { socials = a.socials ? JSON.parse(a.socials) : null; } catch (e) {}
return json(res, 200, { name: a.username ? '@' + a.username : 'member #' + (a.memberId || 0),
avatarUrl: a.avatarUrl || null, bio: a.bio || null, socials, badge,
// profile fields (bio, avatar, socials, intro video) only for a paying member; a free account's wall carries the name, the line's ads and the join call (2026-10-30)
const bought = (await hasBought(a)) && !a.profileQuarantined;
let socials = null; if (bought) { try { socials = a.socials ? JSON.parse(a.socials) : null; } catch (e) {} }
return json(res, 200, { name: a.username ? '@' + a.username : 'member #' + (a.memberId || 0), bought,
avatarUrl: bought ? (a.avatarUrl || null) : null, bio: bought ? (a.bio || null) : null, socials, badge,
joinUrl: joinPath, qrUrl: '/api/qr?d=' + encodeURIComponent('https://instantadpay.com' + joinPath), ladder: finalLadder, unlocked, buyerCount: bc });
}
// -- watch-to-earn video ads: serve one, then reward a server-clock-verified watch
@@ -5781,13 +5821,20 @@ const server = http.createServer(async (req, res) => {
try {
const tok = m[1].toLowerCase();
let a = await accounts.byUsername(tok); if (!a) a = await accounts.byCode(tok);
// a deleted or never-seen name is a real 404, never a bare "Banner wall" page at 200 (a soft 404 Google kept indexed, 2026-10-30)
if (!a) {
const nf = '<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>No wall under that name | InstantAdPay</title><meta name="robots" content="noindex"><link rel="icon" type="image/png" href="/logo-icon.png"><link rel="stylesheet" href="/assets/site.css?v=20260911w"></head><body><section><div class="wrap" style="max-width:720px;text-align:center;padding:60px 0"><h1>No wall under that name</h1><p class="muted">This member page does not exist or was removed.</p><p><a class="btn" href="/">Go to InstantAdPay</a></p></div></section></body></html>';
res.writeHead(404, baseHeaders({ 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-cache', 'X-Robots-Tag': 'noindex' }));
return res.end(nf);
}
let html = fs.readFileSync(path.join(PUBLIC_DIR, 'wall.html'), 'utf8');
if (a) {
const nm = a.username ? '@' + a.username : 'member #' + (a.memberId || 0);
const esc = t => String(t || '').replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
const title = nm + ' on InstantAdPay';
const desc = a.bio ? esc(a.bio).slice(0, 200) : 'Join ' + nm + '’s line on InstantAdPay — instant on-chain ad payouts, free to join.';
const img = a.avatarUrl && /^https:/.test(a.avatarUrl) ? a.avatarUrl : 'https://instantadpay.com/banners/iap-hero-1200x630.png';
const bought = (await hasBought(a)) && !a.profileQuarantined; // only a paying member's avatar becomes the share image
const title = nm + '\u2019s ad wall | InstantAdPay';
const desc = esc(wallDescription(nm)); // fixed site sentence, never the bio (indexed snippet stays ours)
const img = bought && a.avatarUrl && /^https:/.test(a.avatarUrl) ? a.avatarUrl : 'https://instantadpay.com/banners/iap-hero-1200x630.png';
const url = 'https://instantadpay.com/wall/' + (a.username || a.code);
const og = [
'<meta property="og:type" content="profile">',
+133
View File
@@ -0,0 +1,133 @@
// Link-farm scan (Marty, 2026-10-30). BYTE-FOR-BYTE COPY in both repos (InstantAdPay site/ and LinkSpin site/): the two
// sites must flag the same accounts by the same rule; qa/profile-policy.test.cjs on each side hashes this file and
// prohibited.js against the sibling checkout when it is present. Edit one, copy to the other, never fork.
//
// Why: an SEO backlink farm opened 106 free accounts with casino and local-business bios plus a website link, and the public
// walls put that text in front of Google. The accounts are gone; this job finds the next batch before the crawler does.
// What: an in-app daily job (checked every few minutes, claimOnce per Central day, runs at 06:30 Central; replaces a server
// cron) lists accounts with memberId 0 and no wallet that carry a link (URL in the bio, or any social set) AND at least
// one farm signal: a prohibited term in the bio or socials, a sign-in that stopped within 15 minutes of the sign-up, or
// no sponsor at all. Emails on the site's spamScanAllow setting are skipped. The result lands in DATA_DIR/wall-spam-scan.json
// and, only when there are candidates, ONE Telegram goes to the private admin chat. The admin pane "Link-farm list"
// (Admin > Members) shows the rows with delete (the existing DELETE /api/admin/member, which refuses on-chain members) and
// allow (adds the email to spamScanAllow). Nothing is deleted automatically, and nothing cascades to the other site.
'use strict';
const fs = require('fs');
const path = require('path');
const P = require('./prohibited');
const TZ = 'America/Chicago';
const dayOf = ts => new Date(ts).toLocaleDateString('en-CA', { timeZone: TZ });
const minuteOf = ts => { const [h, m] = new Date(ts).toLocaleTimeString('en-GB', { timeZone: TZ, hour: '2-digit', minute: '2-digit', hour12: false }).split(':').map(Number); return h * 60 + m; };
const RUN_AT = 6 * 60 + 30; // 06:30 Central
const QUICK_MS = 15 * 60 * 1000;
const DEFAULT_ALLOW = ['cryptogoat76@gmail.com', 'csicsokaren@gmail.com', 'osamedefe2026@gmail.com'];
const SOCIAL_KEYS = ['facebook', 'twitter', 'youtube', 'instagram', 'tiktok', 'telegram', 'linkedin', 'website', 'video'];
const LINK_KEYS = ['website', 'twitter', 'youtube']; // the fields a farm comes for (quarantine rule at profile save)
let X = null, FILE = null, S = null, running = false;
// opts: { dataDir, site, siteUrl, accounts, siteConfig(), saveSite(patch), notify(text) async, marks?, alsoOn?(email) async -> true|false|null, otherSite }
function init(opts) { X = opts; FILE = path.join(opts.dataDir, 'wall-spam-scan.json'); S = load(); }
function load() { try { return JSON.parse(fs.readFileSync(FILE, 'utf8')); } catch (e) { return { day: null, at: 0, candidates: [], scanned: 0, skipped: 0 }; } }
function save() { try { fs.writeFileSync(FILE, JSON.stringify(S, null, 2)); } catch (e) {} }
async function claimOnce(key) { try { return X.marks ? await X.marks.claim(key) : true; } catch (e) { return true; } }
const norm = e => String(e || '').trim().toLowerCase();
function parseSocials(v) { if (!v) return null; if (typeof v === 'object') return v; try { const o = JSON.parse(v); return o && typeof o === 'object' ? o : null; } catch (e) { return null; } }
// every link a profile carries, socials first, then URLs picked out of the bio
function linksOf(a) {
const out = []; const soc = parseSocials(a.socials) || {};
for (const k of SOCIAL_KEYS) { const v = String(soc[k] || '').trim(); if (v) out.push(v); }
const m = String(a.bio || '').match(/https?:\/\/[^\s<>"']+|(?:www\.)?[a-z0-9-]+(?:\.[a-z0-9-]+)*\.[a-z]{2,24}(?:\/[^\s<>"']*)?/gi);
if (m) for (const u of m) if (!out.includes(u)) out.push(u);
return out;
}
// Allowlist: the site setting (array or comma/space separated string) plus the seeded three.
function allowlist() {
const c = (X && X.siteConfig && X.siteConfig()) || {};
const raw = c.spamScanAllow == null ? DEFAULT_ALLOW : c.spamScanAllow;
const arr = Array.isArray(raw) ? raw : String(raw).split(/[\s,;]+/);
return [...new Set(arr.map(norm).filter(Boolean))];
}
function setAllow(email, on) {
const list = allowlist(); const e = norm(email); if (!e) return list;
const next = on ? [...new Set(list.concat(e))] : list.filter(x => x !== e);
if (X.saveSite) X.saveSite({ spamScanAllow: next.join(', ') });
return next;
}
// The detector. Pure: account in, verdict out. `allow` is a Set of lower-cased emails (defaults to the site allowlist).
function classify(a, allow, now) {
now = now || Date.now();
const r = { email: a.email, candidate: false, reasons: [], links: [] };
if (!a || !a.email) return r;
if (Number(a.memberId) > 0) return r; // a buyer is a member, never a candidate
if (a.address) return r; // a wallet means they came to earn, not to plant a link
const bioUrl = P.hasUrl(a.bio);
const soc = parseSocials(a.socials); const socialsPresent = !!(soc && SOCIAL_KEYS.some(k => String(soc[k] || '').trim()));
if (!bioUrl && !socialsPresent && !a.profileQuarantined) return r;
r.links = linksOf(a);
const term = P.match(a.bio) || (soc ? SOCIAL_KEYS.map(k => P.match(soc[k])).find(Boolean) : null);
if (term) r.reasons.push('prohibited:' + term);
const seen = Number(a.lastSeen) || Number(a.created) || now;
if (Number(a.created) && seen - Number(a.created) < QUICK_MS) r.reasons.push('quick');
if (!a.sponsorRef) r.reasons.push('no-sponsor');
if (a.profileQuarantined) r.reasons.push('quarantined');
if (!r.reasons.length) return r;
if ((allow || new Set(allowlist())).has(norm(a.email))) { r.allowlisted = true; return r; }
r.candidate = true;
return r;
}
// Quarantine rule at profile save (Marty): a brand-new account (memberId 0, no wallet, no sponsor, younger than 24 h)
// whose FIRST profile save carries a URL in the bio or a website / X / YouTube social is saved with profileQuarantined.
function shouldQuarantine(acct, bio, socials, now) {
now = now || Date.now();
if (!acct || Number(acct.memberId) > 0 || acct.address || acct.sponsorRef) return false;
if (!(Number(acct.created) > 0) || now - Number(acct.created) >= 24 * 3600 * 1000) return false;
if (acct.bio || parseSocials(acct.socials)) return false; // not the first save
const soc = parseSocials(socials) || {};
return P.hasUrl(bio) || LINK_KEYS.some(k => String(soc[k] || '').trim());
}
const QUARANTINE_NOTICE = 'Your profile links will appear after your first ad package.';
// One pass over every account. Writes the result file; sends the Telegram when there is anything to review.
async function run(opts) {
if (running) return S; running = true;
try {
const now = Date.now(); const allow = new Set(allowlist());
const all = await X.accounts.listAll(50000, { shells: true });
const names = new Map(); for (const a of all) { if (a.username) names.set(norm(a.username), a); if (a.code) names.set(norm(a.code), a); }
const out = []; let skipped = 0;
for (const a of all) {
const c = classify(a, allow, now);
if (c.allowlisted) { skipped++; continue; }
if (!c.candidate) continue;
const sp = a.sponsorRef ? names.get(norm(a.sponsorRef)) : null;
let alsoOn = null; try { alsoOn = X.alsoOn ? await X.alsoOn(a.email, a) : null; } catch (e) { alsoOn = null; }
out.push({ email: a.email, username: a.username || null, created: Number(a.created) || 0, lastSeen: Number(a.lastSeen) || 0, sponsorRef: a.sponsorRef || '',
sponsorName: sp ? (sp.username ? '@' + sp.username : sp.email) : (a.sponsorRef || null), firstLink: c.links[0] || null, links: c.links.slice(0, 6), reasons: c.reasons,
bio: String(a.bio || '').slice(0, 160), quarantined: !!a.profileQuarantined, alsoOn });
}
out.sort((x, y) => y.created - x.created);
S = { day: dayOf(now), at: now, candidates: out, scanned: all.length, skipped, manual: !!(opts && opts.manual) }; save();
if (out.length && !(opts && opts.quiet)) { try { await X.notify(telegramText(out, now)); S.notified = now; save(); } catch (e) { console.error('spamscan notify', e.message); } }
console.log('spamscan', X.site, 'scanned', all.length, 'candidates', out.length, 'allowlisted', skipped);
return S;
} finally { running = false; }
}
function telegramText(out, now) {
const lines = [X.site + ' link-farm scan: ' + out.length + ' candidate account' + (out.length === 1 ? '' : 's') + ' (' + dayOf(now) + ', ' + X.siteUrl.replace(/^https?:\/\//, '') + ')'];
for (const c of out.slice(0, 15)) lines.push((c.username ? '@' + c.username : c.email) + ' | joined ' + dayOf(c.created || now) + ' | sponsor ' + (c.sponsorName || 'none') + ' | ' + (c.firstLink || 'no link') + (c.alsoOn === true ? ' | also on ' + X.otherSite : ''));
if (out.length > 15) lines.push('... and ' + (out.length - 15) + ' more');
lines.push('Review in Admin > Members > Link-farm list');
return lines.join('\n');
}
// checked every few minutes from server.js: once per Central day, from 06:30 on
async function tick(now) {
now = now || Date.now(); const day = dayOf(now);
if (minuteOf(now) < RUN_AT || S.day === day) return { skipped: true };
if (!await claimOnce('spamscan:' + day)) { S.day = day; save(); return { skipped: true, claimedElsewhere: true }; }
return run();
}
function view() { return { site: X ? X.site : null, otherSite: X ? X.otherSite : null, last: S, allow: allowlist(), running }; }
module.exports = { init, classify, shouldQuarantine, linksOf, allowlist, setAllow, run, tick, view, telegramText, QUARANTINE_NOTICE, DEFAULT_ALLOW, RUN_AT, QUICK_MS, dayOf, minuteOf };