Admin credit grants carry their reason into the member's Credit activity

A correction that reads 'granted by admin' explains nothing to the member looking at
their ledger. The note now travels with the grant, so a credit-consumption correction
names itself where they will actually see it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-17 19:59:13 -05:00
parent cb6da01e1c
commit 3fb123393a
+5 -1
View File
@@ -1593,7 +1593,11 @@ const server = http.createServer(async (req, res) => {
if (b.grantCredits !== undefined) { if (b.grantCredits !== undefined) {
const n = Math.round(Number(b.grantCredits)); const n = Math.round(Number(b.grantCredits));
if (!(n > 0) || n > 100000) return json(res, 400, { error: 'Credits: a whole number from 1 to 100,000.' }); if (!(n > 0) || n > 100000) return json(res, 400, { error: 'Credits: a whole number from 1 to 100,000.' });
await ads.addEarned(e, n, { log: { kind: 'grant', note: 'Credits granted by admin' } }); // The member sees this note in their Credit activity, so let the reason travel with
// the grant. A correction that reads "granted by admin" explains nothing; one that
// names itself is the difference between a refund and a mystery (Marty, 2026-09-17).
const why = String(b.note || '').trim().slice(0, 120) || 'Credits granted by admin';
await ads.addEarned(e, n, { log: { kind: 'grant', note: why } });
console.log('admin credits', e, n, String(b.note || '').slice(0, 100)); console.log('admin credits', e, n, String(b.note || '').slice(0, 100));
} }
return json(res, 200, await adminMember.view(e)); return json(res, 200, await adminMember.view(e));