Wired Wednesday: admin route to post the kickoff now (marks the day sent so 09:00 does not repeat it)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -1332,6 +1332,7 @@ const server = http.createServer(async (req, res) => {
|
||||
if (p === '/api/friday' && req.method === 'GET') return json(res, 200, friday.view(), { 'Cache-Control': 'public, max-age=60' });
|
||||
if (p === '/api/wednesday' && req.method === 'GET') return json(res, 200, wednesday.view(), { 'Cache-Control': 'public, max-age=60' });
|
||||
if (p === '/api/admin/wednesday-previews' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, wednesday.previews()); }
|
||||
if (p === '/api/admin/wednesday/kick' && req.method === 'POST') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); const r = await wednesday.kickNow(); return json(res, r.error ? 400 : 200, r); }
|
||||
// -- the pages a member can turn into a viral link (promo tools > Viral links)
|
||||
if (p === '/api/pages' && req.method === 'GET') {
|
||||
const pages = [{ path: '/', title: 'Home page' }, { path: '/blog', title: 'Blog' }, { path: '/earning', title: 'How earning works' }, { path: '/ledger', title: 'Live ledger' }, { path: '/leaderboard', title: 'Leaderboard' }, { path: '/contract', title: 'The contract' }, { path: '/plays', title: 'Team-building plays' }, { path: '/wallets', title: 'Wallet guide' }, { path: '/friday', title: 'Five Dollar Friday' }, { path: '/whats-new', title: "What's new" }, { path: '/shorts', title: 'Shorts' }];
|
||||
|
||||
+11
-1
@@ -158,4 +158,14 @@ async function broadcast(subject, text) {
|
||||
// what Marty reviews before switching the notice and kickoff on
|
||||
function previews() { const c = cfg(); return { notice: { subject: 'Tomorrow is Wired Wednesday', text: noticeText(c) }, headsUp: headsUpText(c).replace(/<[^>]+>/g, ''), kickoff: kickoffText(c).replace(/<[^>]+>/g, ''), noticeHour: c.noticeHour, tuePost: c.tuePost }; }
|
||||
|
||||
module.exports = { init, cfg, view, stats, onEvent, tick, liveNow, nextWednesday, isWednesday, labelOf, previews };
|
||||
// admin: post the kickoff now instead of waiting for 09:00 CT; marks the day sent so the tick never repeats it (Marty, 2026-09-30)
|
||||
async function kickNow() {
|
||||
const c = cfg(); const now = Date.now(); const day = dayOf(now);
|
||||
if (!isWednesday(now)) return { error: 'It is not Wednesday in Central time.' };
|
||||
if (S.sent['kick:' + day]) return { ok: true, already: true, at: S.sent['kick:' + day] };
|
||||
if (!(await claimOnce('wed:kick:' + day))) return { ok: true, already: true };
|
||||
S.sent['kick:' + day] = now; save();
|
||||
try { await X.telegram(kickoffText(c)); } catch (e) { return { error: 'Telegram send failed: ' + e.message }; }
|
||||
return { ok: true, posted: now };
|
||||
}
|
||||
module.exports = { init, cfg, view, stats, onEvent, tick, liveNow, nextWednesday, isWednesday, labelOf, previews, kickNow };
|
||||
|
||||
Reference in New Issue
Block a user