Admin Member content pane: every page, link, source, zone, ad, postback, upload, profile, broadcast, audience and video members made, in one list
- GET /api/admin/content?type=&q=&from=&to=&flagged=1&page=&per=&fresh=1 (admin only, read-only): content.js normalizes rows from each module's own adminAll() (new one-pass accessors in pages, rotator, sources, zones, postbacks, audiences, messages.adminBroadcasts, videomaker.adminJobs) plus ads.adminList and accounts.listAll; owner shown as @username, email and member #; created in Central time; totals per type; busiest hosts in the current view - Flags: open member reports on an ad, dead or parked destinations, burned link domains, failing postbacks, admin-paused zones, home-page demo links. No deny list exists yet - Row actions only reuse existing moderation routes (campaign pause/resume, zone pause/resume); "Open member" jumps to the member card; page Preview works for drafts and is never counted (admin allowed on ?preview=1) - Uploads: /uploads files now recorded with their uploader in uploads-index.json; older files get the owner from whatever uses them (campaign creative, profile, wall offer) - Credits > Your purchases: buys made from linked positions are included, labelled "Position N" - Cache tags: admin.css 20261018a, admin.js 20261018b, credits-screen.js 20261018b Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -53,6 +53,7 @@ const audiences = require('./audiences'); // first-party retargeting (2026-10-08
|
||||
const MEMBER_AD_TYPES = ['banner', 'text', 'login']; // the formats LinkSpin members can buy (video, visits, featured, solo stay off) // the rotator: rotations, weighted destinations, /r/<code>
|
||||
const snapshot = require('./snapshot'); // daily growth snapshot -> Telegram payments feed (Marty, 2026-09-15)
|
||||
const pipeline = require('./pipeline'); // sponsor follow-up board (coming soon until site setting pipelineMode = on) (Marty, 2026-09-15)
|
||||
const content = require('./content'); // admin Member content: one read-only list of everything members create (2026-10-18)
|
||||
const videomaker = require('./videomaker'); // Circuit tool: promo videos with the member's own end card (ffmpeg in the image) // badge-gated promo toolkit + AI Copy Engine (Surge and up) (Marty, 2026-09-14) // referral contest: /leaderboard, Overview card, weekly + monthly winners (Marty, 2026-09-14) // release notes + roadmap: /whats-new, Overview card, Admin > Releases (Marty, 2026-09-14) // blog -> Blotato -> X + Instagram on publish (Marty, 2026-09-13) // admin member card: search, drilldown, edits (Marty, 2026-09-13) // admin-written coaching articles, server-rendered public /blog with SEO metadata (Marty, 2026-09-12)
|
||||
const TRAFFIC_PAGES = new Set(['/', '/ledger', '/contract', '/shorts', '/plays', '/wallets', '/launch', '/partners', '/publishers', '/earning', '/blog', '/whats-new', '/leaderboard']);
|
||||
let tankWaitCache = null; // dashboard: who is waiting for a sponsor (refreshed every minute)
|
||||
@@ -376,10 +377,12 @@ async function handleUpload(req, res, who) {
|
||||
if (isVideo && spaces.enabled()) {
|
||||
try {
|
||||
const url = await spaces.put('iap-uploads/' + name, buf, ct);
|
||||
content.noteUpload(name, who, buf.length, ct, url); // who uploaded what (admin Member content)
|
||||
return json(res, 200, { url, type: 'video' });
|
||||
} catch (e) { console.error('spaces put', e.message); /* fall through to volume */ }
|
||||
}
|
||||
fs.writeFileSync(path.join(UPLOADS_DIR, name), buf);
|
||||
content.noteUpload(name, who, buf.length, ct, '');
|
||||
return json(res, 200, { url: '/uploads/' + name, type: isVideo ? 'video' : 'image' });
|
||||
}
|
||||
// lead-capture page hooks (og tags + copy live in public/assets/join.js too)
|
||||
@@ -497,6 +500,7 @@ async function boot() {
|
||||
audit.init({ dataDir: DATA_DIR, notify: text => { const sc = siteConfig(); if (sc.telegramBotToken && sc.telegramAdminChatId) telegramSend(sc.telegramAdminChatId, text).catch(() => {}); else if (ADMIN_EMAIL && mailer.hasKey()) mailer.send(ADMIN_EMAIL, 'LinkSpin: counter audit', text).catch(() => {}); } });
|
||||
setTimeout(() => audit.dailyTick(), 5 * 60 * 1000); setInterval(() => audit.dailyTick(), 24 * 60 * 60 * 1000);
|
||||
videomaker.init({ dataDir: DATA_DIR, spaces, accounts });
|
||||
content.init({ dataDir: DATA_DIR, uploadsDir: UPLOADS_DIR, accounts, pages, rotator, sources, zones, ads, postbacks, audiences, messages, videomaker, reports, domains, adminEmail: ADMIN_EMAIL, houseOwner: ads.HOUSE_OWNER, siteHost: SITE_HOST, linkHost: () => domains.live()[0] || SITE_HOST, pagesHost });
|
||||
leaderboard.init({ chain, accounts, ads, dataDir: DATA_DIR, siteConfig, pushFeed, adminEmail: ADMIN_EMAIL,
|
||||
notify: async text => { const sc = siteConfig(); if (!sc.telegramBotToken || !sc.telegramEchoChatId) return; await telegramSend(sc.telegramEchoChatId, text, sc.telegramEchoTopicId); if (String(sc.leaderboardAnnounceGeneral || '1') !== '0') await telegramSend(sc.telegramEchoChatId, text, null); } });
|
||||
setTimeout(() => leaderboard.rolloverTick().catch(e => console.error('leaderboard rollover', e.message)), 90 * 1000);
|
||||
@@ -1031,7 +1035,7 @@ const server = http.createServer(async (req, res) => {
|
||||
const pg = pages.bySlug(pm[1]);
|
||||
const preview = u.searchParams.get('preview') === '1';
|
||||
if (!pg || (pg.status !== 'published' && !preview)) { res.writeHead(404, { 'Content-Type': 'text/html; charset=utf-8' }); return res.end(isLinkHost(req) ? linkSitePage(reqHost(req), 'gone') : '<!doctype html><title>Not found</title><p style="font-family:system-ui;padding:40px">That page is not live.</p>'); }
|
||||
if (preview) { const sess = await auth.fromRequest(req); if (!sess || !sess.email || String(sess.email).toLowerCase() !== pg.owner) { res.writeHead(404, { 'Content-Type': 'text/plain' }); return res.end('Not found'); } }
|
||||
if (preview) { if (!isAdmin(req)) { const sess = await auth.fromRequest(req); if (!sess || !sess.email || String(sess.email).toLowerCase() !== pg.owner) { res.writeHead(404, { 'Content-Type': 'text/plain' }); return res.end('Not found'); } } } // the owner, or the admin (Member content); a preview is never counted
|
||||
else pages.view(pg, req, 'view');
|
||||
const lsid = String(u.searchParams.get('lsid') || '');
|
||||
const hdr = { 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-store', 'X-Content-Type-Options': 'nosniff', 'Referrer-Policy': 'strict-origin-when-cross-origin',
|
||||
@@ -2124,6 +2128,13 @@ const server = http.createServer(async (req, res) => {
|
||||
inviteTokens.set(token, { email: e, exp: Date.now() + 24 * 3600 * 1000, next: /^\/[a-z]/.test(String(b.next || '')) ? String(b.next) : '/ads' });
|
||||
return json(res, 200, { ok: true, url: 'https://' + SITE_HOST + '/welcome/' + token, created: !!r.created });
|
||||
}
|
||||
// -- admin Member content (2026-10-18): every page, link, source, zone, ad, postback, upload, profile, broadcast, audience and
|
||||
// video members made, newest first; read-only (rows point at the existing campaign / zone pause routes)
|
||||
if (p === '/api/admin/content' && req.method === 'GET') {
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||
const sp = u.searchParams;
|
||||
return json(res, 200, await content.query({ type: sp.get('type') || '', q: (sp.get('q') || '').slice(0, 200), from: sp.get('from') || '', to: sp.get('to') || '', flagged: sp.get('flagged') === '1', page: sp.get('page'), per: sp.get('per'), fresh: sp.get('fresh') === '1' }), { 'Cache-Control': 'no-store' });
|
||||
}
|
||||
if (p === '/api/admin/zones' && req.method === 'GET') {
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'Admin only.' });
|
||||
return json(res, 200, { zones: await zones.adminList(), totals: zones.totals(), publishers: zones.publisherTotals(7), rates: zones.settings(), tiers: zones.TIERS, warmup: zones.WARMUP, holdRatio: zones.HOLD_RATIO }, { 'Cache-Control': 'no-store' });
|
||||
@@ -2959,7 +2970,12 @@ const server = http.createServer(async (req, res) => {
|
||||
return json(res, 200, {
|
||||
memberId: id,
|
||||
earnings: await attachNames(evs.filter(e => (e.type === 'TierPaid' && e.recipientId === id) || (e.type === 'AwardPaid' && e.toId === id))),
|
||||
purchases: await attachNames(evs.filter(e => e.type === 'Purchase' && e.buyerId === id)),
|
||||
// buys from the member's linked positions count too (Marty's #353 bought a package that Credits never showed, 2026-10-18);
|
||||
// position = 2, 3 ... in the order the positions were added, null = the main wallet
|
||||
purchases: await (async () => {
|
||||
const posOf = {}; try { if (s.email) (await accounts.positions(s.email)).forEach((ps, i) => { if (ps.memberId && ps.memberId !== id) posOf[ps.memberId] = i + 2; }); } catch (e) {}
|
||||
return attachNames(evs.filter(e => e.type === 'Purchase' && (e.buyerId === id || posOf[e.buyerId])).map(e => Object.assign({}, e, { position: e.buyerId === id ? null : posOf[e.buyerId] })));
|
||||
})(),
|
||||
referrals: await attachNames(evs.filter(e => (e.type === 'MemberActivated' && e.sponsorId === id) || (e.type === 'BuyerCounted' && e.sponsorId === id)))
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user