diff --git a/src/web/routes/guild.js b/src/web/routes/guild.js index 716314c..6916d56 100644 --- a/src/web/routes/guild.js +++ b/src/web/routes/guild.js @@ -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 diff --git a/src/web/routes/guild.test.js b/src/web/routes/guild.test.js index b5b4080..f89dfee 100644 --- a/src/web/routes/guild.test.js +++ b/src/web/routes/guild.test.js @@ -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, / { const content = await router.test("get", "/guild?guild_id=112760669178241024", { sessionData: { managedGuilds: ["112760669178241024"] diff --git a/test/data.js b/test/data.js index 1c7983a..3133d27 100644 --- a/test/data.js +++ b/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: { diff --git a/test/test.js b/test/test.js index 9e595ae..241b7a1 100644 --- a/test/test.js +++ b/test/test.js @@ -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"