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:
@@ -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
|
||||
|
@@ -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 & Arg/)
|
||||
})
|
||||
|
||||
test("web guild: can view bridged guild", async t => {
|
||||
const content = await router.test("get", "/guild?guild_id=112760669178241024", {
|
||||
sessionData: {
|
||||
managedGuilds: ["112760669178241024"]
|
||||
|
63
test/data.js
63
test/data.js
@@ -189,6 +189,69 @@ module.exports = {
|
||||
max_stage_video_channel_users: 300,
|
||||
system_channel_flags: 0|0,
|
||||
safety_alerts_channel_id: null
|
||||
},
|
||||
fna: {
|
||||
application_id: null,
|
||||
roles: [],
|
||||
activity_instances: [],
|
||||
banner: null,
|
||||
stickers: [],
|
||||
joined_at: "2020-04-25T07:36:09.644000+00:00",
|
||||
default_message_notifications: 1,
|
||||
afk_timeout: 60,
|
||||
clan: null,
|
||||
hub_type: null,
|
||||
afk_channel_id: "216367750216548362",
|
||||
discovery_splash: null,
|
||||
splash: null,
|
||||
explicit_content_filter: 0,
|
||||
max_members: 500000,
|
||||
premium_subscription_count: 0,
|
||||
voice_states: [],
|
||||
id: "66192955777486848",
|
||||
premium_tier: 0,
|
||||
name: "Function & Arg",
|
||||
premium_progress_bar_enabled: false,
|
||||
icon: "8bfeb3237cd8697d1d1cd5c626ca8cea",
|
||||
large: true,
|
||||
verification_level: 0,
|
||||
public_updates_channel_id: null,
|
||||
stage_instances: [],
|
||||
rules_channel_id: null,
|
||||
emojis: [],
|
||||
owner_id: "66186356581208064",
|
||||
threads: [],
|
||||
max_stage_video_channel_users: 50,
|
||||
description: null,
|
||||
unavailable: false,
|
||||
features: [
|
||||
"CHANNEL_ICON_EMOJIS_GENERATED",
|
||||
"NEW_THREAD_PERMISSIONS",
|
||||
"THREADS_ENABLED",
|
||||
"SOUNDBOARD"
|
||||
],
|
||||
latest_onboarding_question_id: null,
|
||||
max_video_channel_users: 25,
|
||||
home_header: null,
|
||||
mfa_level: 0,
|
||||
system_channel_id: null,
|
||||
guild_scheduled_events: [],
|
||||
nsfw_level: 0,
|
||||
vanity_url_code: null,
|
||||
member_count: 966,
|
||||
presences: [],
|
||||
application_command_counts: {},
|
||||
system_channel_flags: 0,
|
||||
preferred_locale: "en-US",
|
||||
region: "deprecated",
|
||||
inventory_settings: null,
|
||||
soundboard_sounds: [],
|
||||
version: 1711491959939,
|
||||
incidents_data: null,
|
||||
embedded_activities: [],
|
||||
nsfw: false,
|
||||
safety_alerts_channel_id: null,
|
||||
lazy: true
|
||||
}
|
||||
},
|
||||
user: {
|
||||
|
@@ -29,10 +29,12 @@ const sync = new HeatSync({watchFS: false})
|
||||
|
||||
const discord = {
|
||||
guilds: new Map([
|
||||
[data.guild.general.id, data.guild.general]
|
||||
[data.guild.general.id, data.guild.general],
|
||||
[data.guild.fna.id, data.guild.fna],
|
||||
]),
|
||||
guildChannelMap: new Map([
|
||||
[data.guild.general.id, [data.channel.general.id]],
|
||||
[data.guild.fna.id, []],
|
||||
]),
|
||||
application: {
|
||||
id: "684280192553844747"
|
||||
|
Reference in New Issue
Block a user