fix(commands): keep a staff-gated /guild answer private to the caller
/guild checked the caller's rung against the shard's guilds audience and then posted the permitted answer into the channel, where every member reads it. A moderator running /guild on a staff-gated shard published the guild list (or one guild's counts and leaders) to everyone. The list and detail envelopes now carry ephemeral: true whenever the guilds audience is above the public rung. This module's public rung is `anonymous` (shardVisibility LADDER), not `public`; a missing audience fails closed. Public shards keep public answers. Same rule as module-rust D127. Closes #46 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014HJEmd5sBSpNXicS4gmT1t
This commit is contained in:
@@ -127,6 +127,30 @@ test('a name resolves by abbreviation, then exactly, then by unique prefix', asy
|
||||
assert.equal(ambiguous.ephemeral, true)
|
||||
})
|
||||
|
||||
// #46: the rung check decides WHETHER to answer, not who else reads it. A reply
|
||||
// posted into a channel reaches every member, so an answer the shard gates
|
||||
// above `anonymous` must go to the caller alone — list and detail both.
|
||||
test('a permitted answer narrower than public is private to the caller', async () => {
|
||||
const staff = { ...linked, role: 'moderator', isStaff: true }
|
||||
for (const audience of ['logged_in', 'player', 'staff', 'admin']) {
|
||||
stub({ audience, level: 'admin' })
|
||||
const list = await command.handler({ options: {}, actor: staff })
|
||||
assert.equal(list.title, 'Guilds on this shard')
|
||||
assert.equal(list.ephemeral, true, `list under ${audience}`)
|
||||
const one = await command.handler({ options: { name: 'KOC' }, actor: staff })
|
||||
assert.match(one.title, /Knights of the Codex/)
|
||||
assert.equal(one.ephemeral, true, `detail under ${audience}`)
|
||||
}
|
||||
})
|
||||
|
||||
test('a public answer stays public in the channel', async () => {
|
||||
stub({ audience: 'anonymous', level: 'anonymous' })
|
||||
const list = await command.handler({ options: {}, actor: anonymous })
|
||||
assert.equal(list.ephemeral, false)
|
||||
const one = await command.handler({ options: { name: 'KOC' }, actor: anonymous })
|
||||
assert.equal(one.ephemeral, false)
|
||||
})
|
||||
|
||||
test('a miss is an answer, not a failure', async () => {
|
||||
stub()
|
||||
const res = await command.handler({ options: { name: 'nobody' }, actor: anonymous })
|
||||
|
||||
Reference in New Issue
Block a user