Route native account tools through CP and Imperial Post while retaining Dev access

This commit is contained in:
unimatrixgit 2026-11-15 03:59:47 +01:00
commit c145d26e4b
2 changed files with 169 additions and 2 deletions

View file

@ -4,7 +4,7 @@ import {createSkinResolver,minecraftSkins} from './minecraft-skins.mjs';
const uuid=/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
export async function avatarForAccount(db,userId){
try{const profile=await db.prepare('SELECT avatar_key FROM site_profiles WHERE user_id=?').bind(userId).first();if(profile?.avatar_key)return{url:'/api/avatars/site/'+profile.avatar_key,mode:'image'};}catch{}
try{const linked=await db.prepare('SELECT minecraft_uuid FROM site_game_links WHERE user_id=?').bind(userId).first();if(uuid.test(linked?.minecraft_uuid||''))return{url:'/api/avatars/minecraft/'+linked.minecraft_uuid,mode:'skin'};}catch{}
try{const linked=await db.prepare('SELECT minecraft_uuid FROM site_game_links WHERE user_id=?').bind(userId).first();if(uuid.test(linked?.minecraft_uuid||''))return{url:'/api/avatars/face/'+linked.minecraft_uuid,mode:'image'};}catch{}
return{url:'/api/avatars/fallback',mode:'image'};
}
const fallback='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 8" shape-rendering="crispEdges"><path fill="#976e50" d="M0 0h8v8H0z"/><path fill="#493225" d="M0 0h8v3H0zM0 3h1v2H0zM7 3h1v2H7z"/><path fill="#bc916a" d="M1 3h6v3H1z"/><path fill="#eee8d8" d="M1 4h2v1H1zM5 4h2v1H5z"/><path fill="#5c77b7" d="M2 4h1v1H2zM5 4h1v1H5z"/><path fill="#79513c" d="M3 5h2v1H3zM2 7h4v1H2z"/><path fill="#432c25" d="M2 6h1v1H2zM5 6h1v1H5zM3 7h2v1H3z"/></svg>';

View file

@ -1,4 +1,5 @@
import {protectedStaffRanks,managedRoleSeals,currentStaffRanks} from './game-staff-seals.mjs';
import {OFFICIAL_ACCOUNT} from './official-account.mjs';
import{staffClosureStats,statsForAccount,departmentAwardEarned}from './staff-closure-stats.mjs';
import{spawn}from 'node:child_process';
import{existsSync,readFileSync}from 'node:fs';
@ -6,6 +7,7 @@ import{accessFor}from './permissions.mjs';
import{badgesFor,BADGES,communityBadgeVisible}from './community-badges.mjs';
export function visibleCommunityBadges(keys,ranks){return keys.filter(key=>BADGES.includes(key)&&ranks.length>0&&communityBadgeVisible(key,ranks));}
export function staffSealFor(account,manifest){
if(account.id===OFFICIAL_ACCOUNT.id)return null; // Official showcase identity never uses a personal seal.
const ranks=Array.isArray(account.ranks)?account.ranks:[account.role];
const role=(ranks.includes('owners')||ranks.includes('org_owner_ceo'))?'OWNER':ranks.includes('web_net_admin')?'MAINNETWORKADMIN':ranks.includes('corestaff')?'CORESTAFF':(ranks.includes('network_admin')||ranks.includes('network_admin'))?'NETWORKSTAFF':'';
const named=kind=>Object.values(manifest).find(asset=>asset.role===kind&&asset.label?.toLowerCase()===account.username.toLowerCase())?.footer150||null;