Watch-to-earn videos on Social Tube: signed partner calls /api/partner/watch/next|done
The serve and complete halves of a watch-to-earn video are now videoNextFor / videoDoneFor, used by the member area and by the partner calls, so the daily cap, server-clock watch floor, once-a-day-per-video, advertiser charge and viewer credit are one piece of code. Partner calls: site 'socialtube', member named by email, HMAC with SITE_INVITE_SECRET under the prefix 'watch.v1.', 5 minutes. Credit line reads 'Watched a video on Social Tube'. Chatbot: answer socialtube-earn + prompt line (Marty 2026-11-22). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -214,6 +214,9 @@ const CANNED = [
|
||||
{ id: 'pif', title: 'Pay it forward (PIF)', q: ['How do I PIF someone?', 'Can I buy a package for my referral?', 'Should I fund someone from the tank?'], tags: ['pif', 'pay it forward', 'gift', 'holding tank'],
|
||||
re: /\b(pif|p\.i\.f|pay(ing)? it forward|paid it forward|gift (them|him|her|someone|a member)|send (them|him|her) (some )?pol)\b|\b(fund(ing)?|pay(ing)? for|cover(ing)?|buy(ing)?|purchas(e|ing)|front(ing)?|spot)\b[^.?!]{0,50}\b(for (them|him|her|someone|a member|a new member|my (referral|downline|member))|(their|his|her|someone'?s|a member'?s) (first )?(package|starter|activation|\$?20))\b|\b(front|spot|lend|loan|advance|stake|grubstake)\b[^.?!]{0,30}\b(them|him|her|someone|a member|a new member|my (referral|downline|member))\b/i,
|
||||
a: 'PIF is a gift you send from your own wallet, and the site never touches the money. That is different from other platforms, where the site takes money out of your account balance and buys the position for the other person: InstantAdPay has no balances, so the POL goes straight from your wallet to theirs, and they buy their package themselves, from their own wallet. It only appears on your own free referrals and on members you have adopted, and only once they have linked a wallet, so you cannot PIF somebody who is still sitting in the holding tank. The order is: adopt them from Members > My line > Holding tank, get them to link a wallet on their Wallet tab, then the PIF button shows up, you enter an amount and your own wallet app opens with their address already filled in. Now the part that matters most: do not send anything until you have actually talked to that person and they have told you they will use it. Once that POL leaves your wallet it is gone, there is no refund, no chargeback and nothing we can do to pull it back, because the money goes straight from your wallet to theirs and never touches us. The gift is theirs to keep whatever they do with it, so they can go quiet, spend it on something else, or never sign in again, and none of that is against any rule. Someone in the holding tank joined with nobody working with them and may never have engaged at all, which makes an unanswered PIF the easiest money on this site to lose. Get a reply, get a clear commitment that they are going to buy and build, see that they have linked a wallet and are actually active, and only then decide. If they do buy a $20 package the contract pays you 50 percent as their sponsor and they become one of your qualifying buyers, so a gift that works costs you about half; a gift to somebody who never answers costs you all of it. Never gift money you need, never borrow to do it, and treat every PIF as money you are content to lose.' },
|
||||
{ id: 'socialtube-earn', title: 'Earning credits by watching on Social Tube', q: ['Can I earn credits on Social Tube?', 'What is Earn by watching on Social Tube?', 'Do Social Tube watches count toward my daily limit?'], tags: ['social tube', 'earn by watching', 'socialtube'],
|
||||
re: /(social ?tube.{0,60}\b(earn|credit|watch|paid|limit|cap)|\b(earn|credit|paid)\w*.{0,40}social ?tube)/i,
|
||||
a: 'Yes. Social Tube (socialtube.club) is a video site in the same network. Its Earn page plays the same watch-to-earn video ads you see here in Shorts and Watch videos. Sign in there with your network account, watch a video for its full time, and the credits land in your InstantAdPay balance at the same rate as watching here. InstantAdPay does the timing and the crediting, so the rules are identical: one daily limit shared between the two sites, each video pays once a day, and you are never shown your own video. Your credit activity shows those lines as Watched a video on Social Tube.' },
|
||||
{ id: 'vai-video-ad', title: 'Video App Income: the Run this on InstantAdPay button', q: ['What is the Run this on InstantAdPay button?', 'How do I advertise something I made on Video App Income here?', 'Can a Social Tube page be advertised on InstantAdPay?'], tags: ['video app income', 'social tube', 'run this on instantadpay'],
|
||||
re: /(run (this|it|my video) on instantadpay|(video app income|videoappincome|social ?tube) video.{0,40}\b(ad|advertis|campaign|promot)|\b(ad|advertis|campaign|promot)\w*.{0,40}(video app income|videoappincome|social ?tube) video)/i,
|
||||
a: 'Yes. On Video App Income, open the Share tab, find the video and tap Run this on InstantAdPay. It opens Campaigns here with a Video ad (watch to earn) already filled in: your video, its title, and your Social Tube page as the place the button leads. Nothing is bought for you. You choose the watch length and the budget and press the button yourself, and it is paid with your InstantAdPay ad credits like any other campaign. Members here are paid credits to watch it for the full time, and a tall phone-shaped video plays in Shorts. Two things to know: if you remake or delete that video on Video App Income its file changes, so pause the campaign and start a new one from the new video; and paid views are views, not sales, so nothing about results is promised.' },
|
||||
@@ -478,6 +481,7 @@ ${WEEKEND ? (() => { try { return WEEKEND.fact() || ''; } catch (e) { return '';
|
||||
- The contract cannot be paused, upgraded, or drained. The operator can only manage the ad catalog ($1-$500 bounds, 24h price timelock) and rotate keys.
|
||||
|
||||
- VIDEO APP INCOME VIDEOS AS VIDEO ADS (2026-11-22): a member of Video App Income (a network site that makes short phone videos, shown publicly on Social Tube, socialtube.club) can tap "Run this on InstantAdPay" on that site's Share tab. It opens /my#campaigns with the Video ad (watch to earn) form filled in with their video file, its title and their Social Tube page as the target. Nothing is purchased automatically: the member picks the watch length and budget and submits; it costs their InstantAdPay credits at the normal video rates. Portrait videos play in Shorts. If the video is remade or deleted on Video App Income its file address changes, so the campaign should be paused and a new one made. No results are promised.
|
||||
- EARN BY WATCHING ON SOCIAL TUBE (2026-11-22): Social Tube (socialtube.club, the network's video gallery) has an Earn page that plays InstantAdPay's watch-to-earn video ads. A member signs in there with the network account, watches for the full time, and earns the SAME InstantAdPay credits as in Shorts / Watch videos here. InstantAdPay picks the video, times it, charges the advertiser and credits the viewer, so the daily video limit is ONE limit shared by both sites, each video pays once per day, and nobody is served their own video. Credit activity reads "Watched a video on Social Tube". Advertisers do nothing extra: every live video campaign can also be watched there.
|
||||
PAGES (the ONLY addresses that exist; never invent others): home https://instantadpay.com, member dashboard https://instantadpay.com/my with tabs as hashes: /my#overview, /my#line (My line, holding tank, prospects), /my#pipeline, /my#buy (Buy packages, Qualified Start, Buy POL with a card), /my#campaigns (New campaign, campaign rows, Credit activity), /my#earn (Watch ads, Watch videos, Verified visits, Inbox), /my#earnings (Trace a payment, payouts, referrals, purchases), /my#promo (Your links, Social posts, Text a friend, Email swipes, Banners, Wall, Objections, Videos, Toolkit), /my#training, /my#games (PolHunter, Drip Runner, Gem Kingdom, ClutterHunt, SpellWheel, PolyWarriors, PolyBreak, Spooky Doors in season), /games (public list of every game), /my#wallet, /my#profile, /my#help (Help: support tickets). Public: /support (contact form for anyone signed out or locked out; support@instantadpay.com also works), /join/<username> (invite page, ?v=angle), /wall/<username>, /b/<username>/<badge>, /handout/<username>, /ledger, /tx/<hash>, /contract, /leaderboard, /whats-new, /blog, /plays, /wallets (members), /launch (members), /partners, /earning, /shorts, /terms, /privacy, /disclaimer, /from/faucetwave, /from/tieroneads and /from/socialpix.
|
||||
|
||||
RULES:
|
||||
|
||||
@@ -217,6 +217,45 @@ function loadOpenTokens() {
|
||||
}
|
||||
const gauntletTokens = persistedMap('gauntlet'); // email -> welcome-tour token (server-clock dwell floor)
|
||||
const videoTokens = persistedMap('video'); // email -> watch-to-earn video token (server-clock watch floor)
|
||||
// One watch-to-earn video for a member, and the completion of it (2026-11-22). Shared by the member area (/api/my/videos,
|
||||
// /api/my/videowatch) and the signed partner calls (/api/partner/watch/*, Social Tube), so the daily cap, the server-clock
|
||||
// watch floor, once-a-day-per-video, the advertiser charge and the viewer credit are one piece of code wherever the video plays.
|
||||
async function videoNextFor(email, orientation, g) {
|
||||
const status = await ads.videoStatus(email);
|
||||
if (status.left <= 0) return { ad: null, status };
|
||||
const ad = await ads.serveVideo(Object.assign({ excludeEmail: email, orientation }, g)); // never your own video
|
||||
if (!ad) { // distinguish "you have watched every live video today" from "nothing is live" (Marty, 2026-09-13)
|
||||
let allWatched = false; try { allWatched = !!(await ads.serveVideo(Object.assign({ excludeEmail: email, orientation, ignoreSeen: true }, g))); } catch (e) {}
|
||||
// this surface is empty but the other one may not be: the Watch tab holds the landscape
|
||||
// videos and Shorts holds the portrait ones, and they share one daily cap, so a member
|
||||
// who runs the tab dry still has clips waiting (Marty, 2026-09-22)
|
||||
let otherFormat = null;
|
||||
if (status.left > 0 && (orientation === 'landscape' || orientation === 'portrait')) {
|
||||
const alt = orientation === 'landscape' ? 'portrait' : 'landscape';
|
||||
try { if (await ads.serveVideo(Object.assign({ excludeEmail: email, orientation: alt }, g))) otherFormat = alt === 'portrait' ? 'shorts' : 'watch'; } catch (e) {}
|
||||
}
|
||||
return { ad: null, status, allWatched, otherFormat };
|
||||
}
|
||||
const token = crypto.randomBytes(16).toString('hex');
|
||||
videoTokens.set(email, { token, ts: Date.now(), id: ad.id, secs: ad.watchSecs });
|
||||
return { ad, token, status };
|
||||
}
|
||||
async function videoDoneFor(email, tokenIn, where) { // -> { code, body }; where = '' or a short place name for the credit line (' on Social Tube')
|
||||
const t = videoTokens.get(email);
|
||||
if (!t || t.token !== String(tokenIn || '')) return { code: 400, body: { error: 'That video is no longer open. Load the next one.' } };
|
||||
const age = Date.now() - t.ts;
|
||||
if (age < t.secs * 1000 - 600) return { code: 400, body: { error: 'Watch the full video first.' } };
|
||||
if (age > t.secs * 1000 + 10 * 60 * 1000) { videoTokens.delete(email); return { code: 400, body: { error: 'That watch went stale. Load a fresh video.' } }; }
|
||||
videoTokens.delete(email); // single use
|
||||
if (await ads.hasWatchedVideoToday(email, t.id)) // once-per-day-per-video: no double earning
|
||||
return { code: 200, body: { ok: true, credited: 0, status: await ads.videoStatus(email), already: true } };
|
||||
const tier = await ads.chargeVideoView(t.id); // charge advertiser; null if it ran dry
|
||||
if (!tier) return { code: 200, body: { ok: true, credited: 0, status: await ads.videoStatus(email), gone: true } };
|
||||
await ads.addEarned(email, tier.reward, { log: { kind: 'earn', note: 'Watched a video' + (where || '') + ' (' + tier.secs + 's)' } });
|
||||
await ads.markVideoSeen(email, t.id);
|
||||
const status = await ads.recordVideoWatch(email);
|
||||
return { code: 200, body: { ok: true, credited: tier.reward, status } };
|
||||
}
|
||||
const faucetHits = new Map(); // address -> last faucet ts (rehearsal test-POL faucet rate limit)
|
||||
const visitTokens = persistedMap('visit'); // email -> verified-visit token (dwell + captcha floor)
|
||||
// walk the referral chain upward via sponsorRef (code/username/member id)
|
||||
@@ -3946,6 +3985,32 @@ const server = http.createServer(async (req, res) => {
|
||||
const r = await siteinvite.handle(op, sg.body);
|
||||
return json(res, r.error ? 400 : 200, r);
|
||||
}
|
||||
// -- watch-to-earn videos played on another network site (Social Tube, Marty 2026-11-22: "a member watching on Social Tube earns the same
|
||||
// InstantAdPay credits"). The other site only shows the video: this app picks it, times it on its own clock, charges the advertiser and
|
||||
// credits the viewer through videoNextFor / videoDoneFor, so every rule and the daily cap are shared with the member area.
|
||||
// POST /api/partner/watch/next { site:'socialtube', email, ip?, orientation? } -> { ad, token, status } | { ad:null, status, ... }
|
||||
// POST /api/partner/watch/done { site:'socialtube', email, token } -> { ok, credited, status, already?, gone? }
|
||||
// Signature: X-Watch-Ts (ms) + X-Watch-Sig = hex HMAC-SHA256(SITE_INVITE_SECRET, 'watch.v1.' + ts + '\n' + raw body), 5 minutes.
|
||||
if (p.startsWith('/api/partner/watch/') && req.method === 'POST') {
|
||||
const secret = String(process.env.SITE_INVITE_SECRET || '').trim(); if (secret.length < 32) return json(res, 503, { error: 'not configured' });
|
||||
let raw; try { raw = (await readRaw(req, 16384)).toString('utf8'); } catch (e) { return json(res, 413, { error: 'too big' }); }
|
||||
const ts = String(req.headers['x-watch-ts'] || ''), sig = String(req.headers['x-watch-sig'] || '');
|
||||
if (!/^\d{13}$/.test(ts) || Math.abs(Date.now() - Number(ts)) > 5 * 60000) return json(res, 401, { error: 'stale' });
|
||||
if (!gpSigOk(crypto.createHmac('sha256', secret).update('watch.v1.' + ts + '\n' + raw).digest('hex'), sig)) return json(res, 401, { error: 'bad signature' });
|
||||
let b; try { b = JSON.parse(raw || '{}'); } catch (e) { return json(res, 400, { error: 'bad json' }); }
|
||||
if (!b || String(b.site) !== 'socialtube') return json(res, 400, { error: 'unknown site' });
|
||||
const who = await gpResolve(0, b.email); if (!who) return json(res, 404, { error: 'no such member' });
|
||||
if (fraud.isSuspended(who.email)) return json(res, 403, { error: 'suspended' });
|
||||
const op = p.slice('/api/partner/watch/'.length);
|
||||
if (op === 'next') {
|
||||
const cc = geo.countryOf(String(b.ip || '').slice(0, 60) || 'unknown'), ori = ['portrait', 'landscape'].includes(b.orientation) ? b.orientation : '';
|
||||
const r = await videoNextFor(who.email, ori, { cc, tier: geo.tierOf(cc, siteConfig()) });
|
||||
if (r.ad) r.ad = Object.assign({}, r.ad, { ctaUrl: 'https://instantadpay.com' + r.ad.ctaUrl, videoUrl: /^\//.test(r.ad.videoUrl || '') ? 'https://instantadpay.com' + r.ad.videoUrl : r.ad.videoUrl });
|
||||
return json(res, 200, r);
|
||||
}
|
||||
if (op === 'done') { const vd = await videoDoneFor(who.email, b.token, ' on Social Tube'); return json(res, vd.code, vd.body); }
|
||||
return json(res, 404, { error: 'unknown op' });
|
||||
}
|
||||
if (p === '/api/admin/site-invites' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, await siteinvite.adminView()); }
|
||||
if (p === '/api/admin/site-invites/sample' && req.method === 'POST') { // one sample of the invite email to the admin address only
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); if (!ADMIN_EMAIL) return json(res, 400, { error: 'no admin email set' });
|
||||
@@ -5501,44 +5566,15 @@ const server = http.createServer(async (req, res) => {
|
||||
if (p === '/api/my/videos' && req.method === 'GET') {
|
||||
const s = await auth.fromRequest(req);
|
||||
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const status = await ads.videoStatus(s.email);
|
||||
if (status.left <= 0) return json(res, 200, { ad: null, status });
|
||||
const orientation = String(u.searchParams.get('orientation') || ''); // 'portrait' = Shorts reel, 'landscape' = Watch videos tab
|
||||
const ad = await ads.serveVideo(Object.assign({ excludeEmail: s.email, orientation }, viewerGeo(req))); // never your own video
|
||||
if (!ad) { // distinguish "you have watched every live video today" from "nothing is live" (Marty, 2026-09-13)
|
||||
let allWatched = false; try { allWatched = !!(await ads.serveVideo(Object.assign({ excludeEmail: s.email, orientation, ignoreSeen: true }, viewerGeo(req)))); } catch (e) {}
|
||||
// this surface is empty but the other one may not be: the Watch tab holds the landscape
|
||||
// videos and Shorts holds the portrait ones, and they share one daily cap, so a member
|
||||
// who runs the tab dry still has clips waiting (Marty, 2026-09-22)
|
||||
let otherFormat = null;
|
||||
if (status.left > 0 && (orientation === 'landscape' || orientation === 'portrait')) {
|
||||
const alt = orientation === 'landscape' ? 'portrait' : 'landscape';
|
||||
try { if (await ads.serveVideo(Object.assign({ excludeEmail: s.email, orientation: alt }, viewerGeo(req)))) otherFormat = alt === 'portrait' ? 'shorts' : 'watch'; } catch (e) {}
|
||||
}
|
||||
return json(res, 200, { ad: null, status, allWatched, otherFormat });
|
||||
}
|
||||
const token = crypto.randomBytes(16).toString('hex');
|
||||
videoTokens.set(s.email, { token, ts: Date.now(), id: ad.id, secs: ad.watchSecs });
|
||||
return json(res, 200, { ad, token, status });
|
||||
return json(res, 200, await videoNextFor(s.email, orientation, viewerGeo(req)));
|
||||
}
|
||||
if (p === '/api/my/videowatch' && req.method === 'POST') {
|
||||
const s = await auth.fromRequest(req);
|
||||
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const b = await readBody(req);
|
||||
const t = videoTokens.get(s.email);
|
||||
if (!t || t.token !== String(b.token || '')) return json(res, 400, { error: 'That video is no longer open. Load the next one.' });
|
||||
const age = Date.now() - t.ts;
|
||||
if (age < t.secs * 1000 - 600) return json(res, 400, { error: 'Watch the full video first.' });
|
||||
if (age > t.secs * 1000 + 10 * 60 * 1000) { videoTokens.delete(s.email); return json(res, 400, { error: 'That watch went stale. Load a fresh video.' }); }
|
||||
videoTokens.delete(s.email); // single use
|
||||
if (await ads.hasWatchedVideoToday(s.email, t.id)) // once-per-day-per-video: no double earning
|
||||
return json(res, 200, { ok: true, credited: 0, status: await ads.videoStatus(s.email), already: true });
|
||||
const tier = await ads.chargeVideoView(t.id); // charge advertiser; null if it ran dry
|
||||
if (!tier) return json(res, 200, { ok: true, credited: 0, status: await ads.videoStatus(s.email), gone: true });
|
||||
await ads.addEarned(s.email, tier.reward, { log: { kind: 'earn', note: 'Watched a video (' + tier.secs + 's)' } });
|
||||
await ads.markVideoSeen(s.email, t.id);
|
||||
const status = await ads.recordVideoWatch(s.email);
|
||||
return json(res, 200, { ok: true, credited: tier.reward, status });
|
||||
const vd = await videoDoneFor(s.email, b.token, '');
|
||||
return json(res, vd.code, vd.body);
|
||||
}
|
||||
// -- verified visits: view a member's site (new tab) for the dwell, pass a
|
||||
// human check, and it counts as one guaranteed unique visit for the pack
|
||||
|
||||
Reference in New Issue
Block a user