Badge posts: manual Post to Telegram is admin-only; members' badges still post automatically on unlock

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-13 17:09:59 -05:00
parent 964a02a342
commit e63bc57a99
4 changed files with 13 additions and 8 deletions
+3 -1
View File
@@ -1293,6 +1293,8 @@ const server = http.createServer(async (req, res) => {
if (!held.includes(key)) return json(res, 400, { error: 'You have not unlocked that badge yet.' });
const log = badgeLog(); const mine = log[s.email] || {};
if (mine[key]) return json(res, 200, { ok: true, already: true });
// manual re-posts (the button) are Marty's only; members' badges go out automatically on unlock
if (u.searchParams.get('manual') === '1' && s.email !== ADMIN_EMAIL) return json(res, 403, { error: 'Badges post automatically when they unlock.' });
const a = await accounts.byEmail(s.email);
const who = a && a.username ? '@' + a.username : (a && a.memberId ? 'member #' + a.memberId : 'a member');
const link = a && a.username ? 'instantadpay.com/join/' + a.username : 'instantadpay.com';
@@ -1311,7 +1313,7 @@ const server = http.createServer(async (req, res) => {
if (p === '/api/my/badge-posted' && req.method === 'GET') { // which of my badges are already on Telegram
const s = await auth.fromRequest(req);
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
return json(res, 200, { posted: Object.keys(badgeLog()[s.email] || {}) });
return json(res, 200, { posted: Object.keys(badgeLog()[s.email] || {}), canPost: s.email === ADMIN_EMAIL });
}
if (p === '/api/my/tank/adopt' && req.method === 'POST') {
const s = await auth.fromRequest(req);