[api] add influencer badges

This commit is contained in:
Devin Zuczek
2026-10-08 14:34:04 -04:00
parent 6b8c908771
commit cebeafeb40
12 changed files with 238 additions and 34 deletions
+15 -1
View File
@@ -28,6 +28,7 @@ import type { D1ExecResult } from '../d1'
* runx admin clear-password --username alice [--remote]
* runx admin lookup --username alice [--remote]
* runx admin grant-developer --account 1 [--revoke] [--remote]
* runx admin grant-influencer --account 1 [--revoke] [--remote]
* runx admin grant-plus --username alice [--revoke] [--remote]
* runx admin reload-plus <amount> [--dry-run] [--remote]
* runx admin cai-load [--file <export.json>] [--dry-run] [--remote]
@@ -169,6 +170,11 @@ function grantRoleCommand(name: string, jsonKey: string, roleLabel: string, noun
const grantDeveloper = grantRoleCommand('grant-developer', 'isDeveloper', 'developer')
const grantModerator = grantRoleCommand('grant-moderator', 'isModerator', 'moderator')
/**
* The influencer role, the account's `isInfluencer` flag. `auth` stamps it into the token's
* `role` claim as `influencer` on the next login; nothing else reads the flag.
*/
const grantInfluencer = grantRoleCommand('grant-influencer', 'isInfluencer', 'influencer')
/**
* Rec Room Plus, the account's `hasPlus` flag. Players normally get it themselves by
@@ -394,6 +400,7 @@ const lookup = new Command('lookup')
(json_extract(data, '$.passwordHash') IS NOT NULL) AS hasPassword,
(json_extract(data, '$.isDeveloper') = 1) AS isDeveloper,
(json_extract(data, '$.isModerator') = 1) AS isModerator,
(json_extract(data, '$.isInfluencer') = 1) AS isInfluencer,
(json_extract(data, '$.hasStudio') = 1) AS hasStudio
FROM account WHERE ${where}`
const res = await execSql(sql, remote)
@@ -408,7 +415,13 @@ const lookup = new Command('lookup')
: typeof v === 'object'
? JSON.stringify(v)
: String(v as number | string | boolean)
const boolKeys = new Set(['hasPassword', 'isDeveloper', 'isModerator', 'hasStudio'])
const boolKeys = new Set([
'hasPassword',
'isDeveloper',
'isModerator',
'isInfluencer',
'hasStudio',
])
const table = new Table()
for (const [key, value] of Object.entries(row)) {
const shown = boolKeys.has(key) ? (value === 1 ? 'yes' : 'no') : asText(value)
@@ -426,6 +439,7 @@ export const adminCmd = new Command('admin')
.addCommand(clearPassword)
.addCommand(grantDeveloper)
.addCommand(grantModerator)
.addCommand(grantInfluencer)
.addCommand(grantPlus)
.addCommand(grantStudio)
.addCommand(reloadPlus)