Fix web page exploding for unlinked guilds

Now it should at least show something, though features
like invite won't work correctly. More work needed.
This commit is contained in:
Cadence Ember 2024-12-28 20:01:27 +13:00
parent 20b575c5f7
commit 0fe02dce22
4 changed files with 90 additions and 6 deletions

View file

@ -96,7 +96,7 @@ as.router.get("/guild", defineEventHandler(async event => {
// Unlinked guild
if (!row) {
const links = getChannelRoomsLinks(guild_id, [])
return pugSync.render(event, "guild.pug", {guild_id, nonce, ...links})
return pugSync.render(event, "guild.pug", {guild, guild_id, nonce, ...links})
}
// Linked guild

View file

@ -33,15 +33,34 @@ test("web guild: access denied when guild id messed up", async t => {
t.match(content, /the selected server doesn't exist/)
})
test("web invite: access denied with invalid nonce", async t => {
const content = await router.test("get", "/invite?nonce=1")
t.match(content, /This QR code has expired./)
})
test("web guild: can view guild", async t => {
test("web guild: can view unbridged guild", async t => {
const content = await router.test("get", "/guild?guild_id=66192955777486848", {
sessionData: {
managedGuilds: ["66192955777486848"]
},
api: {
async getStateEvent(roomID, type, key) {
return {}
},
async getMembers(roomID, membership) {
return {chunk: []}
},
async getFullHierarchy(roomID) {
return []
}
}
})
t.match(content, /<h1[^<]*Function &amp; Arg/)
})
test("web guild: can view bridged guild", async t => {
const content = await router.test("get", "/guild?guild_id=112760669178241024", {
sessionData: {
managedGuilds: ["112760669178241024"]