Save three house colours for clan heraldry and future organisation sashes

This commit is contained in:
unimatrix 2026-11-17 02:56:35 +00:00
commit c6eefb10a2

View file

@ -7,7 +7,7 @@ export function createPublicClans(db){return async request=>{
if(!/^[A-Z0-9]{2,6}$/i.test(tag)||url.search)return reply({message:'Clan not found.'},404);
const row=await db.prepare('SELECT id FROM site_clans WHERE tag=? AND active=1').bind(tag.toUpperCase()).first();if(!row)return reply({message:'Clan not found.'},404);
try{const deed=await readClanDeed(db,row.id,{includePolitics:true}),clan=deed.clan,count=await db.prepare('SELECT COUNT(*) total FROM site_clan_members WHERE clan_id=?').bind(clan.id).first();
const result={clan:{id:clan.id,name:clan.name,tag:clan.tag,description:clan.description,homeWorld:clan.home_world,createdAt:Number(clan.created_at),memberCount:Number(count.total),emblem:clanEmblemUrl(clan.id)},members:deed.candidates.filter(m=>m.clan_id===clan.id).map(m=>({username:m.username,title:m.clan_role==='owner'?clanTitles({home_world:clan.home_world,charterKind:deed.kind,institution:clan.institution_key}).owner:m.clan_role==='officer'?'Officer':'Member'})),deed:publicDeed(deed),titles:clanTitles({home_world:clan.home_world,charterKind:deed.kind,institution:clan.institution_key})};
const result={clan:{id:clan.id,name:clan.name,tag:clan.tag,description:clan.description,homeWorld:clan.home_world,createdAt:Number(clan.created_at),colors:deed.colors,memberCount:Number(count.total),emblem:clanEmblemUrl(clan.id)},members:deed.candidates.filter(m=>m.clan_id===clan.id).map(m=>({username:m.username,title:m.clan_role==='owner'?clanTitles({home_world:clan.home_world,charterKind:deed.kind,institution:clan.institution_key}).owner:m.clan_role==='officer'?'Officer':'Member'})),deed:publicDeed(deed),titles:clanTitles({home_world:clan.home_world,charterKind:deed.kind,institution:clan.institution_key})};
return request.method==='HEAD'?new Response(null,{headers:{'Cache-Control':'no-store'}}):reply(result);
}catch(error){if(error instanceof DeedError)return reply({message:error.message},error.status);throw error;}
};}