Walk a living desert
Dunes, oasis trees, cave sietches and darkstone formations up to three plateaus high. Find shelter before the Arrakis sun finds you.
From 79fd7a7f79aa8da6af84c30c68e2041f01a12046 Mon Sep 17 00:00:00 2001 From: unimatrixgit <95320811+unimatrixgit@users.noreply.github.com> Date: Tue, 13 Oct 2026 15:06:02 +0200 Subject: [PATCH] Add independent forums, YouSMP community page and private player support portal --- website/.env.example | 4 +++ website/.openai/hosting.json | 2 +- website/FORUMS-PORTAL.md | 19 +++++++++++ website/README.md | 7 ++-- website/drizzle/0000_forums.sql | 41 +++++++++++++++++++++++ website/drizzle/0001_profiles_tickets.sql | 37 ++++++++++++++++++++ website/drizzle/meta/_journal.json | 1 + website/package.json | 10 +++++- website/scripts/build.mjs | 3 +- website/tests/d1-adapter.mjs | 7 ++++ website/tests/forum-api.test.mjs | 10 ++++++ website/tests/portal-api.test.mjs | 11 ++++++ website/tests/worker.test.mjs | 2 +- website/web/admin.html | 2 +- website/web/arrakis.html | 2 +- website/web/community.css | 3 ++ website/web/discord.html | 1 + website/web/discord.js | 1 + website/web/equipment.html | 2 +- website/web/exchange.html | 2 +- website/web/forums.html | 5 +++ website/web/forums.js | 20 +++++++++++ website/web/index.html | 4 +-- website/web/install.html | 2 +- website/web/manual.html | 2 +- website/web/minecraft.css | 2 ++ website/web/news.html | 2 +- website/web/portal.css | 1 + website/web/portal.html | 1 + website/web/portal.js | 17 ++++++++++ website/web/profile.html | 1 + website/web/races.html | 2 +- website/web/smugglers.html | 2 +- website/web/tickets.html | 1 + website/worker/community-api.mjs | 2 ++ website/worker/forum-api.mjs | 40 ++++++++++++++++++++++ website/worker/portal-api.mjs | 26 ++++++++++++++ website/worker/runtime.mjs | 5 ++- 38 files changed, 284 insertions(+), 18 deletions(-) create mode 100644 website/FORUMS-PORTAL.md create mode 100644 website/drizzle/0000_forums.sql create mode 100644 website/drizzle/0001_profiles_tickets.sql create mode 100644 website/drizzle/meta/_journal.json create mode 100644 website/tests/d1-adapter.mjs create mode 100644 website/tests/forum-api.test.mjs create mode 100644 website/tests/portal-api.test.mjs create mode 100644 website/web/community.css create mode 100644 website/web/discord.html create mode 100644 website/web/discord.js create mode 100644 website/web/forums.html create mode 100644 website/web/forums.js create mode 100644 website/web/portal.css create mode 100644 website/web/portal.html create mode 100644 website/web/portal.js create mode 100644 website/web/profile.html create mode 100644 website/web/tickets.html create mode 100644 website/worker/community-api.mjs create mode 100644 website/worker/forum-api.mjs create mode 100644 website/worker/portal-api.mjs diff --git a/website/.env.example b/website/.env.example index 872bea95..a6548e06 100644 --- a/website/.env.example +++ b/website/.env.example @@ -4,3 +4,7 @@ DISCORD_BOT_TOKEN= DISCORD_PUBLISHER_ID= DISCORD_EXCHANGE_CHANNEL_ID= DISCORD_NEWS_CHANNEL_ID= + +# Comma-separated staff account emails; store as secrets in Sites. +FORUM_ADMIN_EMAILS= +SUPPORT_STAFF_EMAILS= diff --git a/website/.openai/hosting.json b/website/.openai/hosting.json index 2bce02cd..1de37eec 100644 --- a/website/.openai/hosting.json +++ b/website/.openai/hosting.json @@ -1,5 +1,5 @@ { "project_id": "appgprj_6ace145fede88191b193de34d1753c02", - "d1": null, + "d1": "DB", "r2": null } diff --git a/website/FORUMS-PORTAL.md b/website/FORUMS-PORTAL.md new file mode 100644 index 00000000..d639c51b --- /dev/null +++ b/website/FORUMS-PORTAL.md @@ -0,0 +1,19 @@ +# Community and player portal + +The public website has independent Forums and Discord pages. Forums store topics, replies and reports in the hosted D1 database. Reading is public; posting requires ChatGPT sign-in. Public display names are chosen by players. The YouSMP Discord page links the verified community invitation and reads public member/online counts from Discord's invite API. Website discussions are not forwarded to Discord. + +## Private player support + +Open **Player portal → Your profile → Support tickets**. Sign in with ChatGPT and save a display name and optional Minecraft/Discord names. Names are self-reported, not verified account links. A Minecraft name is required for a ban appeal. Choose **Ban appeal** or **Staff support**, enter a subject and full description, then submit. Appeals should describe the ban reason, approximate date and why staff should reconsider it. + +Tickets and replies persist in D1 and are accessible only to the owning account and authorised staff. The owner can reply, close and reopen a closed case. Staff can reply and set Open, In progress, Waiting on player, Resolved or Closed. Each status change appears in the private case history. Closed cases must be reopened before replying. An appeal does not automatically unban a Minecraft account. No Discord messages or notifications are sent by this ticket system; staff should check the portal queue. + +The portal overview lists recent cases and the number of active tickets. The profile page links directly to support tickets. Staff access is checked server-side using trusted Sites identity headers and the secret `SUPPORT_STAFF_EMAILS` allowlist; `FORUM_ADMIN_EMAILS` also grants support access. Configure comma-separated account emails through Sites environment variables, never in source or browser code. The site owner's moderator account is configured initially. Minecraft operator status alone does not grant website permissions. + +Rate limits: three new tickets per hour, five active cases per account, five replies per minute. Requests validate length, use SQL parameters and require same-origin writes. Public topics/replies can be removed by their owner or moderators; authenticated players can report them. Moderators review reports separately from private support tickets. + +## Hosting + +`.openai/hosting.json` declares the `DB` binding. Schema-only migrations live in `drizzle/` and are packaged into `dist/.openai/drizzle`; Sites applies them before publication. Keep applied migration history immutable. Runtime secrets are managed in Sites. Game exchange/news integration remains separately configured through the existing DiscordSRV bridge and Discord bot channels; joining YouSMP does not configure those feeds. + +Build with `node scripts/build.mjs`, then run `node --test tests/*.test.mjs`. Tests use a temporary SQLite database and do not create public topics or real support requests. diff --git a/website/README.md b/website/README.md index 9ae423fe..a1b3b166 100644 --- a/website/README.md +++ b/website/README.md @@ -6,8 +6,11 @@ The home page is a Minecraft-styled banner and navigation hub. Every topic has i Browser files are in `web/`. The server-only Discord API is in `worker/feed-api.mjs`. Hosting configuration is in `.openai/hosting.json`. `node scripts/build.mjs` creates a Worker ESM bundle with the website assets embedded, avoiding separate asset bindings. No dependency installation is required. -Run `node scripts/preview.mjs` for the local site and honest unconnected feed responses. Run `node --test tests/feed-api.test.mjs` for API transport and validation checks. Site publishing uses the supported Sites source workflow and packaging helpers. +Run `node scripts/preview.mjs` for the local site and honest unconnected feed responses. Run `node --test tests/*.test.mjs` for API transport and validation checks. Site publishing uses the supported Sites source workflow and packaging helpers. See [DiscordSRV feed setup](DISCORD-FEEDS.md) for the optional DuneCore 1.0.9 bridge, required server-side secret names, channel setup and snapshot protocol. No credentials are committed or delivered to the browser. Feed data is read-only; trades stay inside Minecraft. -Art is reused from the Project Dune manual and optimized into WebP. Concept-art claims are identified on the page. No game server address or live market records are invented. The website retains the Site's owner-private audience until changed explicitly. +Art is reused from the Project Dune manual and optimized into WebP. Concept-art claims are identified on the page. No game server address or live market records are invented. The website is public. Private portal data requires sign-in and server-side authorisation. + +See [Forums and player support](FORUMS-PORTAL.md) for independent forums, the YouSMP Discord page and private profile-based tickets. + diff --git a/website/drizzle/0000_forums.sql b/website/drizzle/0000_forums.sql new file mode 100644 index 00000000..6b190c7b --- /dev/null +++ b/website/drizzle/0000_forums.sql @@ -0,0 +1,41 @@ +CREATE TABLE forum_topics ( + id TEXT PRIMARY KEY NOT NULL, + category TEXT NOT NULL CHECK(category IN ('help','gameplay','lore','feedback')), + title TEXT NOT NULL, + body TEXT NOT NULL, + author_id TEXT NOT NULL, + author_name TEXT NOT NULL, + created_at INTEGER NOT NULL, + last_activity_at INTEGER NOT NULL, + closed INTEGER NOT NULL DEFAULT 0, + deleted INTEGER NOT NULL DEFAULT 0 +); +--> statement-breakpoint +CREATE INDEX forum_topics_activity ON forum_topics(deleted,last_activity_at); +--> statement-breakpoint +CREATE INDEX forum_topics_author ON forum_topics(author_id,created_at); +--> statement-breakpoint +CREATE TABLE forum_posts ( + id TEXT PRIMARY KEY NOT NULL, + topic_id TEXT NOT NULL REFERENCES forum_topics(id), + body TEXT NOT NULL, + author_id TEXT NOT NULL, + author_name TEXT NOT NULL, + created_at INTEGER NOT NULL, + deleted INTEGER NOT NULL DEFAULT 0 +); +--> statement-breakpoint +CREATE INDEX forum_posts_topic ON forum_posts(topic_id,deleted,created_at); +--> statement-breakpoint +CREATE INDEX forum_posts_author ON forum_posts(author_id,created_at); +--> statement-breakpoint +CREATE TABLE forum_reports ( + id TEXT PRIMARY KEY NOT NULL, + target_type TEXT NOT NULL CHECK(target_type IN ('topic','post')), + target_id TEXT NOT NULL, + reporter_id TEXT NOT NULL, + reason TEXT NOT NULL, + created_at INTEGER NOT NULL, + resolved INTEGER NOT NULL DEFAULT 0, + UNIQUE(target_type,target_id,reporter_id) +); diff --git a/website/drizzle/0001_profiles_tickets.sql b/website/drizzle/0001_profiles_tickets.sql new file mode 100644 index 00000000..69a0e64f --- /dev/null +++ b/website/drizzle/0001_profiles_tickets.sql @@ -0,0 +1,37 @@ +CREATE TABLE player_profiles ( + user_id TEXT PRIMARY KEY NOT NULL, + display_name TEXT NOT NULL, + minecraft_name TEXT NOT NULL DEFAULT '', + discord_name TEXT NOT NULL DEFAULT '', + created_at INTEGER NOT NULL, + updated_at INTEGER NOT NULL +); +--> statement-breakpoint +CREATE TABLE support_tickets ( + id TEXT PRIMARY KEY NOT NULL, + user_id TEXT NOT NULL REFERENCES player_profiles(user_id), + category TEXT NOT NULL CHECK(category IN ('ban-appeal','staff-support')), + subject TEXT NOT NULL, + body TEXT NOT NULL, + status TEXT NOT NULL DEFAULT 'open' CHECK(status IN ('open','in_progress','waiting_on_player','resolved','closed')), + created_at INTEGER NOT NULL, + updated_at INTEGER NOT NULL +); +--> statement-breakpoint +CREATE INDEX support_tickets_owner ON support_tickets(user_id,updated_at); +--> statement-breakpoint +CREATE INDEX support_tickets_status ON support_tickets(status,updated_at); +--> statement-breakpoint +CREATE TABLE support_messages ( + id TEXT PRIMARY KEY NOT NULL, + ticket_id TEXT NOT NULL REFERENCES support_tickets(id), + author_id TEXT NOT NULL, + author_name TEXT NOT NULL, + author_role TEXT NOT NULL CHECK(author_role IN ('player','staff','system')), + body TEXT NOT NULL, + created_at INTEGER NOT NULL +); +--> statement-breakpoint +CREATE INDEX support_messages_ticket ON support_messages(ticket_id,created_at); +--> statement-breakpoint +CREATE INDEX support_messages_author ON support_messages(author_id,created_at); diff --git a/website/drizzle/meta/_journal.json b/website/drizzle/meta/_journal.json new file mode 100644 index 00000000..2609ad3b --- /dev/null +++ b/website/drizzle/meta/_journal.json @@ -0,0 +1 @@ +{"version":"7","dialect":"sqlite","entries":[{"idx":0,"version":"6","when":1791892800000,"tag":"0000_forums","breakpoints":true},{"idx":1,"version":"6","when":1791896400000,"tag":"0001_profiles_tickets","breakpoints":true}]} diff --git a/website/package.json b/website/package.json index f307d713..6af6e018 100644 --- a/website/package.json +++ b/website/package.json @@ -1 +1,9 @@ -{"name":"project-dune-website","private":true,"type":"module","scripts":{"build":"node scripts/build.mjs","test":"node --test tests/feed-api.test.mjs"}} +{ + "name": "project-dune-website", + "private": true, + "type": "module", + "scripts": { + "build": "node scripts/build.mjs", + "test": "node --test tests/*.test.mjs" + } +} diff --git a/website/scripts/build.mjs b/website/scripts/build.mjs index 971d259c..687e36f1 100644 --- a/website/scripts/build.mjs +++ b/website/scripts/build.mjs @@ -2,6 +2,7 @@ import {readFileSync,writeFileSync,readdirSync,statSync,mkdirSync,existsSync,rmS const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..'),web=path.join(root,'web'),dist=path.join(root,'dist'); const assets={};const types={'.html':'text/html; charset=utf-8','.css':'text/css; charset=utf-8','.js':'text/javascript; charset=utf-8','.json':'application/json; charset=utf-8','.webp':'image/webp','.svg':'image/svg+xml'}; function collect(directory){for(const entry of readdirSync(directory)){const p=path.join(directory,entry);if(statSync(p).isDirectory())collect(p);else{const type=types[path.extname(entry)];if(!type)throw Error('Unexpected asset: '+entry);assets['/'+path.relative(web,p).split(path.sep).join('/')]=[type,readFileSync(p).toString('base64')]}}}collect(web); -let api=readFileSync(path.join(root,'worker/feed-api.mjs'),'utf8').replace(/export /g,'');let runtime=readFileSync(path.join(root,'worker/runtime.mjs'),'utf8').replace("import {handleFeed} from './feed-api.mjs';",''); +let api=['feed-api.mjs','forum-api.mjs','community-api.mjs','portal-api.mjs'].map(file=>readFileSync(path.join(root,'worker',file),'utf8').replace(/export /g,'')).join('\n');let runtime=readFileSync(path.join(root,'worker/runtime.mjs'),'utf8').replace(/^import .*;$/gm,''); if(existsSync(dist)){const resolved=path.resolve(dist);if(resolved!==path.join(root,'dist'))throw Error('Invalid dist directory');rmSync(resolved,{recursive:true,force:true})} mkdirSync(path.join(dist,'server'),{recursive:true});mkdirSync(path.join(dist,'.openai'),{recursive:true});writeFileSync(path.join(dist,'server/index.js'),'const ASSET_DATA='+JSON.stringify(assets)+';\n'+api+'\n'+runtime);cpSync(path.join(root,'.openai/hosting.json'),path.join(dist,'.openai/hosting.json'));console.log('Built Worker with',Object.keys(assets).length,'embedded website assets'); +if(existsSync(path.join(root,'drizzle')))cpSync(path.join(root,'drizzle'),path.join(dist,'.openai/drizzle'),{recursive:true}); diff --git a/website/tests/d1-adapter.mjs b/website/tests/d1-adapter.mjs new file mode 100644 index 00000000..5c36271e --- /dev/null +++ b/website/tests/d1-adapter.mjs @@ -0,0 +1,7 @@ +import {DatabaseSync} from 'node:sqlite'; +export class LocalD1 { + constructor(schema,filename=':memory:'){this.sqlite=new DatabaseSync(filename);this.sqlite.exec('PRAGMA foreign_keys=ON');if(schema)this.sqlite.exec(schema)} + prepare(sql){const db=this.sqlite;let values=[];return {bind(...args){values=args;return this},async first(){return db.prepare(sql).get(...values)||null},async all(){return {results:db.prepare(sql).all(...values)}},async run(){const r=db.prepare(sql).run(...values);return {success:true,meta:{changes:Number(r.changes)}}}}} + async batch(statements){this.sqlite.exec('BEGIN');try{const results=[];for(const s of statements)results.push(await s.run());this.sqlite.exec('COMMIT');return results}catch(error){this.sqlite.exec('ROLLBACK');throw error}} + close(){this.sqlite.close()} +} diff --git a/website/tests/forum-api.test.mjs b/website/tests/forum-api.test.mjs new file mode 100644 index 00000000..f74f47a8 --- /dev/null +++ b/website/tests/forum-api.test.mjs @@ -0,0 +1,10 @@ +import test from 'node:test';import assert from 'node:assert/strict';import {readFileSync,mkdtempSync,rmSync} from 'node:fs';import {tmpdir} from 'node:os';import path from 'node:path';import {handleForum} from '../worker/forum-api.mjs';import {LocalD1} from './d1-adapter.mjs'; +const schema=readFileSync(new URL('../drizzle/0000_forums.sql',import.meta.url),'utf8'); +function request(endpoint,{user,method='GET',body,origin='https://example.test',email}={}){return new Request('https://example.test/api/forum'+endpoint,{method,headers:{'Content-Type':'application/json',Origin:origin,...(user?{'oai-authenticated-user-id':user}:{}),...(email?{'oai-authenticated-user-email':email}:{})},...(body?{body:JSON.stringify(body)}:{})})} +async function create(env){const r=await handleForum(request('/topics',{user:'alice',method:'POST',body:{title:'An Arrakis expedition',body:'How should I prepare my first stillsuit?',displayName:'Alice',category:'help'}}),env);assert.equal(r.status,201);return (await r.json()).id} +test('Anonymous readers can browse but cannot post',async()=>{const DB=new LocalD1(schema);try{const list=await handleForum(request('/topics'),{DB});assert.deepEqual((await list.json()).topics,[]);const r=await handleForum(request('/topics',{method:'POST',body:{}}),{DB});assert.equal(r.status,401)}finally{DB.close()}}); +test('Topics and replies persist, with public identity IDs excluded',async()=>{const directory=mkdtempSync(path.join(tmpdir(),'dune-forum-test-')),file=path.join(directory,'forum.sqlite');let DB=new LocalD1(schema,file);try{const id=await create({DB});const reply=await handleForum(request('/topics/'+id+'/replies',{user:'bob',method:'POST',body:{displayName:'Bob',body:'Equip all four tagged pieces.'}}),{DB});assert.equal(reply.status,201);DB.close();DB=new LocalD1(null,file);const response=await handleForum(request('/topics/'+id),{DB});const data=await response.json();assert.equal(data.replies.length,1);assert.equal(data.replies[0].body,'Equip all four tagged pieces.');assert.equal(data.topic.canManage,false);assert.ok(!JSON.stringify(data).includes('author_id'))}finally{DB.close();rmSync(directory,{recursive:true,force:true})}}); +test('Cross-site writes and forged management attempts fail',async()=>{const DB=new LocalD1(schema);try{const id=await create({DB});assert.equal((await handleForum(request('/topics/'+id,{method:'DELETE',user:'bob'}),{DB})).status,403);assert.equal((await handleForum(request('/topics',{method:'POST',user:'bob',origin:'https://other.test',body:{}}),{DB})).status,403)}finally{DB.close()}}); +test('Closed topics reject replies and can be reopened by their owner',async()=>{const DB=new LocalD1(schema);try{const id=await create({DB});assert.equal((await handleForum(request('/topics/'+id+'/close',{method:'POST',user:'alice',body:{closed:true}}),{DB})).status,200);const reply=await handleForum(request('/topics/'+id+'/replies',{user:'bob',method:'POST',body:{body:'Test reply',displayName:'Bob'}}),{DB});assert.equal(reply.status,409);assert.equal((await handleForum(request('/topics/'+id+'/close',{method:'POST',user:'alice',body:{closed:false}}),{DB})).status,200)}finally{DB.close()}}); +test('Post validation, rate limits and parameterized search resist abuse',async()=>{const DB=new LocalD1(schema);try{await create({DB});const second=await handleForum(request('/topics',{user:'alice',method:'POST',body:{title:'Another topic',body:'A second post too soon.',displayName:'Alice',category:'help'}}),{DB});assert.equal(second.status,429);assert.equal((await handleForum(request('/topics',{user:'bob',method:'POST',body:{title:'x',body:'Short',displayName:'Bob',category:'help'}}),{DB})).status,400);const search=await handleForum(request('/topics?q='+encodeURIComponent("' OR 1=1 --")),{DB});assert.deepEqual((await search.json()).topics,[])}finally{DB.close()}}); +test('Reports are visible only to moderators; removal hides rather than erases',async()=>{const DB=new LocalD1(schema),env={DB,FORUM_ADMIN_EMAILS:'owner@example.invalid'};try{const id=await create(env);const report=await handleForum(request('/reports',{user:'bob',method:'POST',body:{targetType:'topic',targetId:id,reason:'Please review this topic.'}}),env);assert.equal(report.status,201);assert.equal((await handleForum(request('/reports',{user:'bob'}),env)).status,403);const moderator={user:'owner',email:'owner@example.invalid'};const reports=await handleForum(request('/reports',moderator),env);assert.equal((await reports.json()).reports.length,1);assert.equal((await handleForum(request('/topics/'+id,{...moderator,method:'DELETE'}),env)).status,200);assert.equal((await handleForum(request('/topics/'+id),env)).status,404);assert.equal(DB.sqlite.prepare('SELECT deleted FROM forum_topics WHERE id=?').get(id).deleted,1)}finally{DB.close()}}); diff --git a/website/tests/portal-api.test.mjs b/website/tests/portal-api.test.mjs new file mode 100644 index 00000000..65a9c6b4 --- /dev/null +++ b/website/tests/portal-api.test.mjs @@ -0,0 +1,11 @@ +import test from 'node:test';import assert from 'node:assert/strict';import {readFileSync,mkdtempSync,rmSync} from 'node:fs';import {tmpdir} from 'node:os';import path from 'node:path';import {LocalD1} from './d1-adapter.mjs';import {handlePortal} from '../worker/portal-api.mjs'; +const schema=['0000_forums','0001_profiles_tickets'].map(n=>readFileSync(new URL('../drizzle/'+n+'.sql',import.meta.url),'utf8')).join('\n'); +function req(endpoint,user='alice',method='GET',body,email,origin='https://example.test'){return new Request('https://example.test/api/'+endpoint,{method,headers:{'Content-Type':'application/json',Origin:origin,...(user?{'oai-authenticated-user-id':user}:{}),...(email?{'oai-authenticated-user-email':email}:{})},...(body!==undefined?{body:JSON.stringify(body)}:{})})} +const profile={displayName:'Alice',minecraftName:'DesertPlayer',discordName:'OptionalHandle'}; +async function setup(env){assert.equal((await handlePortal(req('profile','alice','POST',profile),env)).status,200);const r=await handlePortal(req('tickets','alice','POST',{category:'ban-appeal',subject:'Please review my ban',body:'I would like staff to review the reason for my ban.'}),env);assert.equal(r.status,201);return (await r.json()).id} +test('Portal data requires authentication and same-origin writes',async()=>{const DB=new LocalD1(schema);try{assert.equal((await handlePortal(req('profile',null),{DB})).status,401);assert.equal((await handlePortal(req('profile','alice','POST',profile,null,'https://evil.test'),{DB})).status,403);assert.equal((await handlePortal(req('profile','alice','POST',null),{DB})).status,400)}finally{DB.close()}}); +test('Tickets are tied to profiles and appeals require a Minecraft name',async()=>{const DB=new LocalD1(schema);try{const body={category:'ban-appeal',subject:'Review my account ban',body:'Here is my explanation for staff review.'};assert.equal((await handlePortal(req('tickets','alice','POST',body),{DB})).status,422);await handlePortal(req('profile','alice','POST',{...profile,minecraftName:''}),{DB});assert.equal((await handlePortal(req('tickets','alice','POST',body),{DB})).status,422);body.category='staff-support';assert.equal((await handlePortal(req('tickets','alice','POST',body),{DB})).status,201)}finally{DB.close()}}); +test('Other players cannot read or alter a private ticket',async()=>{const DB=new LocalD1(schema);try{const id=await setup({DB});assert.equal((await handlePortal(req('tickets/'+id,'bob'),{DB})).status,404);assert.equal((await handlePortal(req('tickets/'+id+'/replies','bob','POST',{body:'Forged reply'}),{DB})).status,404);assert.equal((await handlePortal(req('tickets/'+id+'/status','bob','POST',{status:'closed'}),{DB})).status,404);assert.deepEqual((await (await handlePortal(req('tickets','bob'),{DB})).json()).tickets,[]);assert.equal((await handlePortal(req('tickets?view=staff','bob'),{DB})).status,403);const own=await (await handlePortal(req('tickets/'+id),{DB})).json();assert.ok(!JSON.stringify(own).includes('user_id'));assert.equal(own.ticket.minecraft_name,'DesertPlayer')}finally{DB.close()}}); +test('Only authorised staff can triage; replies carry verified staff roles',async()=>{const DB=new LocalD1(schema),env={DB,SUPPORT_STAFF_EMAILS:'staff@example.invalid'};try{const id=await setup(env);assert.equal((await handlePortal(req('tickets/'+id+'/status','alice','POST',{status:'resolved'}),env)).status,403);assert.equal((await handlePortal(req('tickets/'+id+'/status','moderator','POST',{status:'in_progress'},'staff@example.invalid'),env)).status,200);assert.equal((await handlePortal(req('tickets/'+id+'/replies','moderator','POST',{body:'We are reviewing your case.',author_role:'player'},'staff@example.invalid'),env)).status,201);const data=await (await handlePortal(req('tickets/'+id),env)).json();assert.equal(data.ticket.status,'in_progress');assert.equal(data.messages.find(m=>m.body==='We are reviewing your case.').author_role,'staff');assert.equal((await (await handlePortal(req('tickets?view=staff','moderator','GET',undefined,'staff@example.invalid'),env)).json()).tickets.length,1)}finally{DB.close()}}); +test('Owners close and reopen tickets; closed cases block replies and rate limits apply',async()=>{const DB=new LocalD1(schema),env={DB};try{const id=await setup(env);await handlePortal(req('tickets/'+id+'/status','alice','POST',{status:'closed'}),env);assert.equal((await handlePortal(req('tickets/'+id+'/replies','alice','POST',{body:'Hello again'}),env)).status,409);await handlePortal(req('tickets/'+id+'/status','alice','POST',{status:'open'}),env);for(let i=0;i<5;i++)assert.equal((await handlePortal(req('tickets/'+id+'/replies','alice','POST',{body:'Reply number '+i}),env)).status,201);assert.equal((await handlePortal(req('tickets/'+id+'/replies','alice','POST',{body:'Too many replies'}),env)).status,429)}finally{DB.close()}}); +test('Private profiles and ticket history persist after database restart',async()=>{const dir=mkdtempSync(path.join(tmpdir(),'dune-tickets-')),file=path.join(dir,'db.sqlite');let DB=new LocalD1(schema,file);try{const id=await setup({DB});DB.close();DB=new LocalD1(null,file);assert.equal((await (await handlePortal(req('tickets/'+id),{DB})).json()).ticket.subject,'Please review my ban');assert.equal((await (await handlePortal(req('tickets'),{DB})).json()).activeCount,1);assert.equal((await (await handlePortal(req('profile','bob'),{DB})).json()).profile,null)}finally{DB.close();rmSync(dir,{recursive:true,force:true})}}); diff --git a/website/tests/worker.test.mjs b/website/tests/worker.test.mjs index 9a5dc432..a2b02dae 100644 --- a/website/tests/worker.test.mjs +++ b/website/tests/worker.test.mjs @@ -1,4 +1,4 @@ import test from 'node:test';import assert from 'node:assert/strict';import worker from '../dist/server/index.js'; -test('Built Worker serves all ten separate pages and site assets',async()=>{for(const path of ['/','/arrakis.html','/smugglers.html','/equipment.html','/admin.html','/install.html','/manual.html','/races.html','/exchange.html','/news.html','/manual-data.json','/assets/item-0.webp']){const response=await worker.fetch(new Request('https://example.test'+path),{});assert.equal(response.status,200,path);assert.ok((await response.arrayBuffer()).byteLength>0,path)}}); +test('Built Worker serves all fifteen separate pages and site assets',async()=>{for(const path of ['/','/arrakis.html','/smugglers.html','/equipment.html','/admin.html','/install.html','/manual.html','/races.html','/exchange.html','/news.html','/forums.html','/discord.html','/portal.html','/profile.html','/tickets.html','/manual-data.json','/assets/item-0.webp']){const response=await worker.fetch(new Request('https://example.test'+path),{});assert.equal(response.status,200,path);assert.ok((await response.arrayBuffer()).byteLength>0,path)}}); test('Built Worker retains unconnected feed state without leaking secrets',async()=>{const response=await worker.fetch(new Request('https://example.test/api/news'),{});const text=await response.text();assert.equal(JSON.parse(text).status,'not_connected');assert.ok(!text.includes('DISCORD_BOT_TOKEN'))}); test('Unsupported paths and write requests are rejected',async()=>{assert.equal((await worker.fetch(new Request('https://example.test/missing'),{})).status,404);assert.equal((await worker.fetch(new Request('https://example.test/api/exchange',{method:'POST'}),{})).status,405)}); diff --git a/website/web/admin.html b/website/web/admin.html index 7f5cec53..bd9d003a 100644 --- a/website/web/admin.html +++ b/website/web/admin.html @@ -1 +1 @@ -
PROJECT DUNE / MINECRAFT REALMS
The Imperial Scepter. Your operator controls for the worlds and their inhabitants.

04 / KEEPERS OF THE REALMS
Operators receive the Imperial Admin Scepter automatically. Right-click the modified blaze rod to open the administration GUI.
GUI controls require operator status. Sandworm summoning uses the dune.admin permission.
PROJECT DUNE / MINECRAFT REALMS
The Imperial Scepter. Your operator controls for the worlds and their inhabitants.

04 / KEEPERS OF THE REALMS
Operators receive the Imperial Admin Scepter automatically. Right-click the modified blaze rod to open the administration GUI.
GUI controls require operator status. Sandworm summoning uses the dune.admin permission.
PROJECT DUNE / MINECRAFT REALMS
The desert world. Spice, survival, sietches and Shai-Hulud.
01 / ARRAKIS FIELD NOTES
Water is precious. Spice is power. Every expedition begins with a stillsuit and ends with a story.

Dunes, oasis trees, cave sietches and darkstone formations up to three plateaus high. Find shelter before the Arrakis sun finds you.
Use the tagged Spice Harvest Shovel to collect melange. Sell for Solaris, fill CHOAM quotas, or work a player-sponsored spice contract.
A desert-skinned Sniffer carries the sandworm’s form, with native zombie AI. Survive the encounter; its death leaves a rich spice field.
A WORD FROM THE SPACING GUILD
A sighting begins with coordinates on Arrakis. Fifteen real minutes later, the Guild announces it across the proxy network.
PROJECT DUNE / MINECRAFT REALMS
The desert world. Spice, survival, sietches and Shai-Hulud.
01 / ARRAKIS FIELD NOTES
Water is precious. Spice is power. Every expedition begins with a stillsuit and ends with a story.

Dunes, oasis trees, cave sietches and darkstone formations up to three plateaus high. Find shelter before the Arrakis sun finds you.
Use the tagged Spice Harvest Shovel to collect melange. Sell for Solaris, fill CHOAM quotas, or work a player-sponsored spice contract.
A desert-skinned Sniffer carries the sandworm’s form, with native zombie AI. Survive the encounter; its death leaves a rich spice field.
A WORD FROM THE SPACING GUILD
A sighting begins with coordinates on Arrakis. Fifteen real minutes later, the Guild announces it across the proxy network.
PROJECT DUNE / COMMUNITY
Meet the community beyond the dunes.
Y O U S M P / C O M M U N I T YTHE YOUsMP DISCORD COMMUNITY
Meet the YouSMP community, talk about the network and find other players. The Discord community and this website's discussion forum are separate.
Checking the Discord community…

Questions, expeditions, lore and feedback live in the Project Dune forums. Read publicly; use ChatGPT sign-in to post.
Open the forums →
Read YouSMP's current rules and conduct before joining its Minecraft network.
Read YouSMP rules ↗
The Dune news and exchange feeds use the separately configured DiscordSRV bridge. Joining Discord does not connect those game feeds.
Open Guild dispatches →PROJECT DUNE / MINECRAFT REALMS
Tagged stillsuits, harvest tools and an inventory ready for the dunes.
THE INVENTORY / EQUIP YOUR EXPEDITION
Familiar Minecraft materials. Dune rules, tagged equipment, and a purpose for every piece of your kit.

Survive Arrakis in a complete faction set.

Dig the deposits. Gather the wealth of worlds.

Trade spice for Solaris and fulfill contracts.

A precious cargo for hidden sietches.

Upgrade with Elytra and 1,000,000 Solaris.

Your Nether Star opens the realm menus.

A tagged Wind Charge with explosive impact.
The operator’s key to the admin GUI.
Select an item to open its manual chapter. Illustrated icons are reference art; in-game equipment uses the models and resource pack described in the guide.



PROJECT DUNE / MINECRAFT REALMS
Tagged stillsuits, harvest tools and an inventory ready for the dunes.
THE INVENTORY / EQUIP YOUR EXPEDITION
Familiar Minecraft materials. Dune rules, tagged equipment, and a purpose for every piece of your kit.

Survive Arrakis in a complete faction set.

Dig the deposits. Gather the wealth of worlds.

Trade spice for Solaris and fulfill contracts.

A precious cargo for hidden sietches.

Upgrade with Elytra and 1,000,000 Solaris.

Your Nether Star opens the realm menus.

A tagged Wind Charge with explosive impact.
The operator’s key to the admin GUI.
Select an item to open its manual chapter. Illustrated icons are reference art; in-game equipment uses the models and resource pack described in the guide.



LIVE REALM RECORDS / DISCORDSRV
Trade beyond the dunes.
Browse live buy and sell offers, and player-sponsored harvesting contracts. Listings come from the connected game server through DiscordSRV.
Checking the server connection…
Player-posted listings are spice harvesting contracts: 15% of earnings go to the worker, 85% to the sponsor. They are distinct from item sell orders. The normal spice sale is a standing sale to the economy at 15 Solaris per unit by default, with the Imperial bonus and Trust levy applied in game.
The website is a read-only market board. Complete trades or accept contracts inside Minecraft. It does not spend Solaris or hold items.
Read the exchange manual →LIVE REALM RECORDS / DISCORDSRV
Trade beyond the dunes.
Browse live buy and sell offers, and player-sponsored harvesting contracts. Listings come from the connected game server through DiscordSRV.
Checking the server connection…
Player-posted listings are spice harvesting contracts: 15% of earnings go to the worker, 85% to the sponsor. They are distinct from item sell orders. The normal spice sale is a standing sale to the economy at 15 Solaris per unit by default, with the Imperial bonus and Trust levy applied in game.
The website is a read-only market board. Complete trades or accept contracts inside Minecraft. It does not spend Solaris or hold items.
Read the exchange manual →PROJECT DUNE / COMMUNITY
Questions, expeditions, lore and ideas. Your own place in the sietch.
Opening the forum…

PAPER 1.21.4 JAVA 21 PROJECT DUNE
A desert worth surviving.
A universe worth building.
Bring Arrakis to Minecraft. Choose your House, walk the dunes, harvest melange, and face the maker beneath the sand.

PAPER 1.21.4 JAVA 21 PROJECT DUNE
A desert worth surviving.
A universe worth building.
Bring Arrakis to Minecraft. Choose your House, walk the dunes, harvest melange, and face the maker beneath the sand.