Link-farm hardening (2026-10-30 incident: 106 free accounts synced from InstantAdPay carried casino bios and website links; 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 of InstantAdPay's): 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) are refused in bios, social URLs, line banner targets, wall offers and every campaign field, with the refusal logged. The registry ingest from InstantAdPay drops a bio with a link or a prohibited term instead of storing it; iapsync applies the same on the way out.
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 as InstantAdPay): 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 "LinkSpin link-farm scan" Telegram to the private admin chat only when there are candidates. Admin > Members > Link-farm list: rows with "also on InstantAdPay" (local registry mirror), Delete selected (existing DELETE /api/admin/member, on-chain refused, no cascade) and Allow.
Terms section 9 "Prohibited content", bio hint in the profile editor, chatbot canned answer + kb-seed entry "What content is not allowed?", KNOWLEDGE_DATE 2026-10-30. Test: qa/profile-policy.test.cjs (unit + local copy, hash check against the InstantAdPay copies; runs in qa/run.sh member and policy).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
+7
-4
@@ -36,6 +36,7 @@ const pub = a => a ? { email: a.email, sponsorRef: a.sponsorRef || '', code: a.c
|
||||
username: a.username || null, memberId: a.memberId || 0, joinedVia: a.joinedVia || null, joinedRef: a.joinedRef || null,
|
||||
lineBannerUrl: a.lineBannerUrl || null, lineTargetUrl: a.lineTargetUrl || null, wallOffers: a.wallOffers || null,
|
||||
avatarUrl: a.avatarUrl || null, bio: a.bio || null, socials: a.socials || null,
|
||||
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}$/;
|
||||
@@ -116,12 +117,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) };
|
||||
},
|
||||
@@ -229,7 +231,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,
|
||||
avatarUrl: r.avatar_url, bio: r.bio, socials: r.socials, 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 = {
|
||||
@@ -284,10 +286,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 touchSeen(e) { await db.q('UPDATE accounts SET last_seen=? WHERE email=?', [Date.now(), e]); },
|
||||
@@ -488,7 +491,7 @@ module.exports = { init, signup, login, ensure, onChange, byEmail, byAddress, by
|
||||
setUsername, setMemberId, namesForMembers, listByReferrer, downline, linkWallet, onWalletLinked, count,
|
||||
setLineBanner: (e, b, t) => impl().setLineBanner(String(e || '').toLowerCase(), b, t),
|
||||
setWallOffers: (e, j) => impl().setWallOffers(String(e || '').toLowerCase(), j),
|
||||
setProfile: (e, a, bio, socials) => impl().setProfile(String(e || '').toLowerCase(), a, bio, socials).then(tap(String(e || '').toLowerCase())),
|
||||
setProfile: (e, a, bio, socials, quarantined) => impl().setProfile(String(e || '').toLowerCase(), a, bio, socials, quarantined).then(tap(String(e || '').toLowerCase())),
|
||||
touchSeen: e => impl().touchSeen(String(e || '').toLowerCase()),
|
||||
adminSetAddress: (e, a) => impl().adminSetAddress(String(e || '').toLowerCase(), a ? normAddr(a) : null).then(tap(String(e || '').toLowerCase())),
|
||||
positionByAddress: a => impl().positionByAddress(normAddr(a)),
|
||||
|
||||
+5
-1
File diff suppressed because one or more lines are too long
@@ -90,6 +90,7 @@ async function bootstrap() {
|
||||
await alterSafe('ALTER TABLE accounts ADD COLUMN socials VARCHAR(1200) NULL'); // JSON {platform:url}
|
||||
await alterSafe('ALTER TABLE accounts ADD COLUMN line_banner_url VARCHAR(500) NULL');
|
||||
await alterSafe('ALTER TABLE accounts ADD COLUMN line_target_url VARCHAR(500) NULL');
|
||||
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 q(`CREATE TABLE IF NOT EXISTS daily_views (
|
||||
email VARCHAR(190) NOT NULL,
|
||||
day CHAR(10) NOT NULL,
|
||||
|
||||
+5
-2
@@ -30,6 +30,7 @@
|
||||
// Until InstantAdPay answers proto 2, the hash of a row carrying the new facts is not recorded (sent again later).
|
||||
'use strict';
|
||||
const SF = require('./sponsorfollow');
|
||||
const prohibited = require('./prohibited'); // 2026-10-30: a profile that fails the policy never leaves this site
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
@@ -52,10 +53,12 @@ function save() { try { fs.writeFileSync(FILE(), JSON.stringify(load())); } catc
|
||||
function init(deps) { R = deps; load(); } // { dataDir, accounts, registry, host, follow (sponsorfollow store), tank: () => tank }
|
||||
const PUBLIC = () => String(process.env.PUBLIC_URL || ('https://' + (R.host || 'linkspin.app'))).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 }, 'LinkSpin'); // 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;
|
||||
if (!avatarUrl && !bio && !(socials && Object.keys(socials).length)) return null;
|
||||
return { avatarUrl, bio, socials: socials && Object.keys(socials).length ? socials : null };
|
||||
}
|
||||
|
||||
+5
-1
@@ -56,6 +56,10 @@ const FAQ = [
|
||||
{ id: 'f-recovery-phrase', title: 'Recovery phrase and scam safety', source: 'faq',
|
||||
questions: ['Someone asked for my recovery phrase', 'Will support ever ask for my private key?', 'Someone messaged me asking for money'],
|
||||
tags: ['recovery phrase', 'private key', 'scam', 'security'],
|
||||
answer: 'Never share your recovery phrase (the 12 or 24 words) or private key with anyone: whoever has them has your money. Nobody from LinkSpin will ever ask for them, and the site never sees them. If someone does ask, do not reply, and tell support through Help at ' + SITE_URL + '/help.' }
|
||||
answer: 'Never share your recovery phrase (the 12 or 24 words) or private key with anyone: whoever has them has your money. Nobody from LinkSpin will ever ask for them, and the site never sees them. If someone does ask, do not reply, and tell support through Help at ' + SITE_URL + '/help.' },
|
||||
{ id: 'f-prohibited-content', title: 'What content is not allowed?', source: 'faq',
|
||||
questions: ['What content is not allowed?', 'Can I put a link in my bio?', 'Why was my bio refused?', 'Can I promote a casino or CBD offer?', 'What is link farming?'],
|
||||
tags: ['prohibited content', 'rules', 'bio', 'links', 'gambling', 'adult', 'link farm', 'terms'],
|
||||
answer: 'Not allowed anywhere on LinkSpin, in 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 of your profile. Your bio, avatar and social links show on your public wall once you have bought a package; a free account\'s wall shows the name, the line\'s ads and the join button. Accounts created to place links in profile fields (link farming) are removed without notice, with their profile text. Full list: ' + SITE_URL + '/terms#prohibited' },
|
||||
];
|
||||
module.exports = { FAQ };
|
||||
|
||||
+108
@@ -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
@@ -233,6 +233,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 InstantAdPay; the "also on InstantAdPay" 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-content" hidden>
|
||||
@@ -535,6 +541,6 @@
|
||||
|
||||
<script src="/assets/common.js?v=20261023ov"></script>
|
||||
<script src="/assets/admin-kb.js?v=20261020kb"></script>
|
||||
<script src="/assets/admin.js?v=20261027nr"></script><script src="/assets/admin-sponsorcheck.js?v=20261022sc"></script><script src="/assets/admin-refill.js?v=20261024rf"></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-refill.js?v=20261024rf"></script><script src="/assets/admin-kits.js?v=20261024kit"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+27
-1
@@ -307,6 +307,7 @@
|
||||
} catch (e) {}
|
||||
}
|
||||
async function loadMembers() {
|
||||
loadSpamScan().catch(() => {});
|
||||
loadTank();
|
||||
const r = await api('/api/admin/members');
|
||||
allMembers = r.members || [];
|
||||
@@ -325,6 +326,31 @@
|
||||
+ '<td class="act"><button class="btn small sec" data-mcopen="' + esc(a.email) + '">Open</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. InstantAdPay 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-spon]'); if (!b) return;
|
||||
const v = await IAP.ask({ title: 'Sponsor for ' + b.dataset.spon, text: 'Username, share code, or member #. Leave blank to clear.', value: b.dataset.cur, ok: 'Save' });
|
||||
@@ -352,7 +378,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
@@ -2448,7 +2448,7 @@
|
||||
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());
|
||||
|
||||
@@ -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 LinkSpin — join through this page and you\'re in my line.';
|
||||
IAP.$('bioText').textContent = (w.bought && w.bio) || 'Building a team on LinkSpin. 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
@@ -108,6 +108,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>
|
||||
@@ -848,6 +849,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%">
|
||||
@@ -1012,7 +1014,7 @@
|
||||
<script src="/assets/tools.js?v=20261011a"></script>
|
||||
<script src="/assets/wallet.js?v=20261021a"></script>
|
||||
<script src="/assets/promo.js?v=20261020bs3"></script>
|
||||
<script src="/assets/my.js?v=20261027nr"></script>
|
||||
<script src="/assets/my.js?v=20261030pp"></script>
|
||||
<script src="/assets/chat.js?v=20261016a"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+6
-3
@@ -40,11 +40,14 @@
|
||||
<p>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>
|
||||
<h2 class="disp">8. Acceptable use</h2>
|
||||
<p>No fraud, bots, fake traffic, self-dealing to farm rewards, attempts to manipulate the contract, or abuse of other members. We may suspend or terminate accounts that break these rules.</p>
|
||||
<h2 class="disp">9. No warranty</h2>
|
||||
<h2 class="disp">9. Prohibited content</h2>
|
||||
<div id="prohibited"></div>
|
||||
<p>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>
|
||||
<h2 class="disp">10. No warranty</h2>
|
||||
<p>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>
|
||||
<h2 class="disp">10. Limitation of liability</h2>
|
||||
<h2 class="disp">11. Limitation of liability</h2>
|
||||
<p>To the fullest extent permitted by law, LinkSpin 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>
|
||||
<h2 class="disp">11. Changes and termination</h2>
|
||||
<h2 class="disp">12. Changes and termination</h2>
|
||||
<p>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 style="margin-bottom:0">See also the <a href="/disclaimer">Disclaimer</a> and <a href="/privacy">Privacy Policy</a>.</p>
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -48,6 +48,6 @@
|
||||
</div>
|
||||
</section>
|
||||
<script src="/assets/common.js?v=20261023ov"></script>
|
||||
<script src="/assets/wall.js?v=20261008a"></script>
|
||||
<script src="/assets/wall.js?v=20261030pp"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -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('casino', 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);
|
||||
})();
|
||||
@@ -12,6 +12,7 @@
|
||||
# bash qa/run.sh nas # Network Ad Space billing: stop snapshot, active-only reconcile, restart without phantom delivery, the 1/N network + partner-zone rate (stubbed NAS, throwaway data)
|
||||
# bash qa/run.sh loginqueue # prepaid login-slot queue: ads.js unit test (two app copies promoting at once) + HTTP/Ads-screen e2e on a local copy
|
||||
# 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 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 fuel # Fuel Your Offers: refill notices, refuel streak, Refuel Kit, Engine Room (unit + two-copy tests, throwaway data)
|
||||
# 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/.
|
||||
@@ -57,6 +58,9 @@ elif [ "$MODE" = "override" ]; then
|
||||
node qa/override.test.cjs || status=1
|
||||
elif [ "$MODE" = "member" ]; then
|
||||
start_local 8796 && { LOCAL=http://127.0.0.1:8796 node qa/walk.mjs member || status=1; }; stop_local 8796
|
||||
node qa/profile-policy.test.cjs || status=1
|
||||
elif [ "$MODE" = "policy" ]; then
|
||||
node qa/profile-policy.test.cjs || status=1
|
||||
elif [ "$MODE" = "sponsorfollow" ]; then
|
||||
node qa/sponsorfollow.test.cjs || status=1
|
||||
node qa/carry-hold.test.cjs || status=1
|
||||
|
||||
@@ -67,6 +67,8 @@ const convtrack = require('./convtrack'); // conversion pixel: goals, ad click i
|
||||
const marks = require('./marks'); // one-time claims shared by both app copies during a deploy (event_marks or exclusive files), 2026-10-24
|
||||
const refill = require('./refill');
|
||||
const refuel = require('./refuel');
|
||||
const prohibited = require('./prohibited'); // prohibited-content policy shared with InstantAdPay (2026-10-30 link-farm incident)
|
||||
const spamscan = require('./spamscan'); // daily link-farm scan + quarantine rule, byte-for-byte copy of InstantAdPay's
|
||||
const kit = require('./kit');
|
||||
const engine = require('./engine'); // the Engine Room (same file as InstantAdPay), 2026-10-24
|
||||
const kitspin = require('./kitspin'); // Refuel Kit -> Banner Spin loader // the Refuel Kit: monthly members-only LinkSpin banner sets, personalized per member (2026-10-24) // Monthly Refuel streak, LinkSpin side: reports $25+ packages to InstantAdPay (the source of truth), applies its grants (2026-10-24) // refill notices: low / out / idle, one message per owner, conversions tracked (2026-10-24)
|
||||
@@ -174,6 +176,14 @@ const faucetHits = new Map(); // address -> last faucet ts (rehearsal test-POL f
|
||||
const visitTokens = persistedMap('visit'); // email -> verified-visit token (dwell + captcha floor)
|
||||
// walk the referral chain upward via sponsorRef (code/username/member id)
|
||||
const polUsdC = { at: 0, v: 0 }; // /api/public/polusd cache (2026-10-22)
|
||||
// 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 LinkSpin: 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);
|
||||
@@ -647,6 +657,13 @@ async function boot() {
|
||||
linkFor: async email => { const a = await accounts.byEmail(email); if (!a) return null; const tok = a.username || a.code; return tok ? { username: a.username || null, link: SITE_URL + '/join/' + tok } : null; } });
|
||||
setTimeout(() => refuel.tick().catch(e => console.error('refuel', e.message)), 75000);
|
||||
setInterval(() => refuel.tick().catch(e => console.error('refuel', e.message)), 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: 'LinkSpin', siteUrl: SITE_URL, otherSite: 'InstantAdPay', 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); if (ADMIN_EMAIL && mailer.hasKey()) return mailer.send(ADMIN_EMAIL, 'LinkSpin link-farm scan', text); },
|
||||
alsoOn: async (email, a) => (a && a.joinedVia === 'instantadpay') ? true : !!(await registry.get(email)) }); // the local registry mirror of InstantAdPay's rows, never a cascade
|
||||
setTimeout(() => spamscan.tick().catch(e => console.error('spamscan', e.message)), 150000);
|
||||
setInterval(() => spamscan.tick().catch(e => console.error('spamscan', e.message)), 5 * 60 * 1000);
|
||||
refill.init({ dataDir: DATA_DIR, siteConfig, ads, accounts, chain, mailer, drip, marks, siteUrl: SITE_URL, houseOwner: ads.HOUSE_OWNER, streakLine: email => refuel.streakLine(email),
|
||||
creditsFor: async email => { const v = await adminMember.view(email); return (v && v.credits && v.credits.available) || 0; },
|
||||
message: async (to, subject, html) => { await messages.deliver(1, ADMIN_EMAIL || 'house@' + SITE_HOST, [to], subject, html, 'notice'); } });
|
||||
@@ -783,6 +800,7 @@ function siteConfig() {
|
||||
telegramBotToken: '', telegramChatId: '', telegramTopicId: '', telegramEvents: 'payouts', telegramCtaUrl: SITE_URL + '/',
|
||||
telegramEchoChatId: '', telegramEchoTopicId: '', telegramEchoEvents: 'payouts', // shared cross-program payments topic
|
||||
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
|
||||
launchAt: '', // public launch moment, ISO 8601 with offset (e.g. 2026-09-18T19:00:00-05:00): countdown on /launch + dashboard mark
|
||||
aiCreditsPerGen: 10, aiFreeSurge: 20, aiFreeCircuit: 60, aiFreeNexus: 150, // AI Copy Engine: free generations per month by badge, then credits per generation
|
||||
carryClaimDays: '3',
|
||||
@@ -1644,7 +1662,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) {} }
|
||||
}
|
||||
return json(res, 200, { ref: tok, sponsorId, sponsorBlocked, sponsorRouted, tankHold: intentBuy ? null : tankHold, sponsorName: spd.name || null, invited: !!(tok || showTok), name, avatarUrl, own, bio: typeof bio === 'undefined' ? null : bio, cobrand: typeof cobrand === 'undefined' ? false : cobrand });
|
||||
}
|
||||
@@ -2193,6 +2211,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);
|
||||
@@ -2841,8 +2868,10 @@ const server = http.createServer(async (req, res) => {
|
||||
if (r.wallet && !a.address) wallets.push([e, r.wallet]);
|
||||
if (r.profile && typeof r.profile === 'object') { // the InstantAdPay profile fills only what is still empty here; the member can change it on this side any time (Marty 2026-10-11)
|
||||
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, 'LinkSpin'); if (cp.dropped.length) console.log('registry profile dropped', String(e).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(x => x !== undefined)) { try { await accounts.setProfile(e, upd[0], upd[1], upd[2]); updated++; } catch (err) {} }
|
||||
}
|
||||
@@ -3358,7 +3387,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 = {};
|
||||
@@ -3370,8 +3399,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 || {}), 'LinkSpin', { 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);
|
||||
}
|
||||
// -- wall positions 2 & 3: the member's own offers, unlocked at 2 / 5 qualifying buyers
|
||||
@@ -3388,6 +3426,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 }, 'LinkSpin'); 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);
|
||||
@@ -3400,6 +3439,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 }, 'LinkSpin'); 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();
|
||||
@@ -3465,9 +3505,11 @@ const server = http.createServer(async (req, res) => {
|
||||
badge = { img: '/badges/badge-' + t[0] + '.jpg?v=3', 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(SITE_URL + joinPath), ladder: finalLadder, unlocked, buyerCount: bc });
|
||||
}
|
||||
// -- watch-to-earn video ads: serve one, then reward a server-clock-verified watch
|
||||
@@ -4178,13 +4220,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 | LinkSpin</title><meta name="robots" content="noindex"><link rel="icon" type="image/png" href="/logo-icon.png"><link rel="stylesheet" href="/assets/site.css?v=ls20260916a"></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 LinkSpin</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 => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
||||
const title = nm + ' on LinkSpin';
|
||||
const desc = a.bio ? esc(a.bio).slice(0, 200) : 'Join ' + nm + '’s line on LinkSpin — instant on-chain ad payouts, free to join.';
|
||||
const img = a.avatarUrl && /^https:/.test(a.avatarUrl) ? a.avatarUrl : SITE_URL + '/banners/linkspin-og-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 | LinkSpin';
|
||||
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 : SITE_URL + '/banners/linkspin-og-1200x630.png';
|
||||
const url = SITE_URL + '/wall/' + (a.username || a.code);
|
||||
const og = [
|
||||
'<meta property="og:type" content="profile">',
|
||||
|
||||
+133
@@ -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 };
|
||||
Reference in New Issue
Block a user