From 9bef4470cff8c1471385af5b5904d1972e52b330 Mon Sep 17 00:00:00 2001 From: unimatrixgit <95320811+unimatrixgit@users.noreply.github.com> Date: Mon, 16 Nov 2026 17:00:55 +0100 Subject: [PATCH] dev: define scoped organisation forum access and record approved sash art --- docs/design/SYSTEM-BOARDS.md | 45 +++++++++++++++++++ .../merch/art/house-colours-20261116.md | 25 +++++++++++ website/node/system-board-access.mjs | 26 +++++++++++ website/tests/system-board-access.test.mjs | 29 ++++++++++++ 4 files changed, 125 insertions(+) create mode 100644 docs/design/SYSTEM-BOARDS.md create mode 100644 website/integrations/azuriom/merch/art/house-colours-20261116.md create mode 100644 website/node/system-board-access.mjs create mode 100644 website/tests/system-board-access.test.mjs diff --git a/docs/design/SYSTEM-BOARDS.md b/docs/design/SYSTEM-BOARDS.md new file mode 100644 index 00000000..a1712cea --- /dev/null +++ b/docs/design/SYSTEM-BOARDS.md @@ -0,0 +1,45 @@ +# System Boards + +Implementation batch: access projection. Not yet connected to native MyBB; +no private forum should be provisioned until native permissions and feed +exclusion are installed and tested. + +## Agreed structure + +System Boards is one bottom-of-index category, collapsed by default. Clan +Boards, Company Boards and Election Board live beneath it. Clan and company +CPs embed their own organisation board. The menu structure is shared. + +Use MyBB's native forum permissions, moderator records and inheritance. +Membership is authoritative in the central organisation records, never in +browser parameters. Revoke stale managed forum groups before content is +served, retaining unrelated political and staff groups. Existing staff retain +global moderation. The Big 4.1 retain inspection rights; inspection itself +does not grant moderation. Clan owners moderate only their own subtree and +can create unlimited nested forums/categories there. No global ACP access. + +`website/node/system-board-access.mjs` is the shared server-side projection. +Clan owners must have both current ownership and the owner membership role. +Company access reuses the current founder/CEO registry; scoped management +belongs to the current CEO. Additional company-member roles must use the +actual membership service when it is implemented, rather than fabricated +memberships. Every identity refresh must reload the projection, so leaving, +removal and changes of ownership invalidate old grants. + +Public feeds, search, attachments, direct links and main-index counts must +respect private forum permissions. The existing website's public forum-feed +adapter also needs explicit exclusion of private System Boards descendants. + +Election topics are discussions of already confirmed candidatures. MyBB does +not create candidatures, cast votes or decide election results. Publish topics +idempotently by application ID; never expose private application records. + +## Pending integration + +- Idempotent native provisioning and managed groups/permissions. +- Request-time identity refresh and revocation in the existing MyBB bridge. +- Scoped child-forum management with CSRF protection and ancestry checks. +- Shared embedded board renderer and Clan/Company/Election navigation. +- Confirmed-candidature topic publication, public-feed exclusions and live QA. + +Keep umbrella PR #337 open. Publish completed batches only after CI. diff --git a/website/integrations/azuriom/merch/art/house-colours-20261116.md b/website/integrations/azuriom/merch/art/house-colours-20261116.md new file mode 100644 index 00000000..1c38d7af --- /dev/null +++ b/website/integrations/azuriom/merch/art/house-colours-20261116.md @@ -0,0 +1,25 @@ +# Approved House sash artwork + +The four individual merchandise images were redesigned with the built-in image +editor. Existing catalogue names and heraldic shield symbols are preserved. + +| Shop house | Dune reference | Side bands | Central band | Asset | +| --- | --- | --- | --- | --- | +| Aerdrecht | Atreides | Royal blue | Warm ivory/silver | sash-aerdrecht-v1.png | +| Oordwijk | Ordos | Emerald green | Champagne | sash-oordwijk-v1.png | +| Harkveen | Harkonnen | Deep crimson red | Dark steel grey | sash-harkveen-v1.png | +| Korenholt | Corrino | Imperial purple | Antique gold | sash-korenholt-v1.png | + +Shared editing prompt: Change the cloth palette to the side/central colours +above, with no black central stripe. Preserve the full isolated vertical sash, +silver rope edging, silver tie and fringe, gold embroidery, original heraldic +shield and exact house lettering. Preserve DUNEREALMS, UNIMATRIX999 and +PRINCEPS TER ELECTUS. Refine realistic embroidered satin with crisp lettering. +Keep the entire sash in frame on a genuinely transparent background, with no +scenery, extra objects or UI. All four use the same catalogue presentation. + +Publication: artwork commit 77644d70 passed Web CI run 340 before the four +native shop assets were replaced. HTTP 200, PNG content types and all four +SHA-256 digests were verified against local artwork. Shop data, checkout, +prices and eligibility were unchanged. The collection overview illustration +is a separate legacy asset and is not regenerated by this batch. diff --git a/website/node/system-board-access.mjs b/website/node/system-board-access.mjs new file mode 100644 index 00000000..b26d1e69 --- /dev/null +++ b/website/node/system-board-access.mjs @@ -0,0 +1,26 @@ +// Native forum projections are derived from current organisation records on +// every sign-in/identity refresh. Never accept memberships from browser input. +export function projectSystemBoardAccess({clans=[],companies=[],userId,inspectAll=false,moderateAll=false}={}){ + const grants=new Map(); + if(typeof userId!=='string'||!userId)return {version:1,inspectAll:false,moderateAll:false,organisations:[]}; + for(const clan of clans){ + if(Number(clan.active)!==1||clan.user_id!==userId||!['owner','officer','member'].includes(clan.clan_role))continue; + grants.set('clan:'+clan.id,{kind:'clan',id:clan.id,read:true,post:true,manage:clan.owner_id===userId&&clan.clan_role==='owner'}); + } + for(const company of companies){ + if(company.status!=='active'||company.founded_by!==userId&&company.ceo_account_id!==userId)continue; + // Founder access follows the existing Company CP. Current management, + // including scoped moderation, belongs to the appointed CEO. + grants.set('company:'+company.id,{kind:'company',id:company.id,read:true,post:true,manage:company.ceo_account_id===userId}); + } + return {version:1,inspectAll:inspectAll===true,moderateAll:moderateAll===true,organisations:[...grants.values()].sort((a,b)=>(a.kind+':'+a.id).localeCompare(b.kind+':'+b.id))}; +} + +export async function loadSystemBoardAccess(db,user,{inspectAll=false,moderateAll=false}={}){ + if(!user?.id)return projectSystemBoardAccess(); + const [{results:clans=[]},{results:companies=[]}]=await Promise.all([ + db.prepare('SELECT c.id,c.active,c.owner_id,m.user_id,m.clan_role FROM site_clans c JOIN site_clan_members m ON m.clan_id=c.id WHERE m.user_id=? AND c.active=1').bind(user.id).all(), + db.prepare('SELECT id,status,founded_by,ceo_account_id FROM corrino_companies WHERE founded_by=? OR ceo_account_id=?').bind(user.id,user.id).all() + ]); + return projectSystemBoardAccess({clans,companies,userId:user.id,inspectAll,moderateAll}); +} diff --git a/website/tests/system-board-access.test.mjs b/website/tests/system-board-access.test.mjs new file mode 100644 index 00000000..ad02ba81 --- /dev/null +++ b/website/tests/system-board-access.test.mjs @@ -0,0 +1,29 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import {projectSystemBoardAccess} from '../node/system-board-access.mjs'; + +const clan={id:'ours',active:1,user_id:'member',owner_id:'leader',clan_role:'member'}; +test('private board membership excludes other users, inactive clans and departed users',()=>{ + const access=projectSystemBoardAccess({userId:'member',clans:[clan,{...clan,id:'other',user_id:'other'},{...clan,id:'closed',active:0}]}); + assert.deepEqual(access.organisations,[{kind:'clan',id:'ours',read:true,post:true,manage:false}]); + assert.equal(projectSystemBoardAccess({userId:'member',clans:[]}).organisations.length,0); +}); +test('only verified current clan ownership grants subtree management',()=>{ + for(const role of ['member','officer','owner']){ + const result=projectSystemBoardAccess({userId:'member',clans:[{...clan,clan_role:role}]}).organisations[0]; + assert.equal(result.manage,false); + } + assert.equal(projectSystemBoardAccess({userId:'member',clans:[{...clan,owner_id:'member',clan_role:'owner'}]}).organisations[0].manage,true); +}); +test('company founder and CEO access remain distinct; unrelated and inactive companies are excluded',()=>{ + const company={id:'company',status:'active',founded_by:'founder',ceo_account_id:'ceo'}; + const view=userId=>projectSystemBoardAccess({userId,companies:[company]}).organisations; + assert.equal(view('founder')[0].manage,false);assert.equal(view('ceo')[0].manage,true);assert.deepEqual(view('stranger'),[]); + assert.deepEqual(projectSystemBoardAccess({userId:'ceo',companies:[{...company,status:'closed'}]}).organisations,[]); +}); +test('inspection is not moderation, and neither can be enabled with truthy strings or an anonymous identity',()=>{ + assert.deepEqual(projectSystemBoardAccess({inspectAll:true,moderateAll:true}),{version:1,inspectAll:false,moderateAll:false,organisations:[]}); + assert.equal(projectSystemBoardAccess({userId:'owner',inspectAll:true}).moderateAll,false); + assert.equal(projectSystemBoardAccess({userId:'member',inspectAll:'true',moderateAll:1}).inspectAll,false); + assert.equal(projectSystemBoardAccess({userId:'mod',moderateAll:true}).moderateAll,true); +});