Add test for linking to an autocreate disabled guild
This commit is contained in:
parent
55fbb4c48e
commit
4b40c16711
2 changed files with 12 additions and 3 deletions
|
@ -6,8 +6,6 @@ const Ty = require("../../types")
|
|||
const DiscordTypes = require("discord-api-types/v10")
|
||||
|
||||
const {discord, db, as, sync, select, from} = require("../../passthrough")
|
||||
/** @type {import("../../d2m/actions/create-space")} */
|
||||
const createSpace = sync.require("../../d2m/actions/create-space")
|
||||
const {reg} = require("../../matrix/read-registration")
|
||||
|
||||
/**
|
||||
|
@ -28,6 +26,15 @@ function getCreateRoom(event) {
|
|||
return event.context.createRoom || sync.require("../../d2m/actions/create-room")
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {H3Event} event
|
||||
* @returns {import("../../d2m/actions/create-space")}
|
||||
*/
|
||||
function getCreateSpace(event) {
|
||||
/* c8 ignore next */
|
||||
return event.context.createSpace || sync.require("../../d2m/actions/create-space")
|
||||
}
|
||||
|
||||
const schema = {
|
||||
linkSpace: z.object({
|
||||
guild_id: z.string(),
|
||||
|
@ -100,6 +107,7 @@ as.router.post("/api/link", defineEventHandler(async event => {
|
|||
const session = await useSession(event, {password: reg.as_token})
|
||||
const api = getAPI(event)
|
||||
const createRoom = getCreateRoom(event)
|
||||
const createSpace = getCreateSpace(event)
|
||||
|
||||
// Check guild ID or nonce
|
||||
const guildID = parsedBody.guild_id
|
||||
|
|
|
@ -47,7 +47,7 @@ class Router {
|
|||
/**
|
||||
* @param {string} method
|
||||
* @param {string} inputUrl
|
||||
* @param {{event?: any, params?: any, body?: any, sessionData?: any, api?: Partial<import("../src/matrix/api")>, snow?: {[k in keyof SnowTransfer]?: Partial<SnowTransfer[k]>}, createRoom?: Partial<import("../src/d2m/actions/create-room")>, headers?: any}} [options]
|
||||
* @param {{event?: any, params?: any, body?: any, sessionData?: any, api?: Partial<import("../src/matrix/api")>, snow?: {[k in keyof SnowTransfer]?: Partial<SnowTransfer[k]>}, createRoom?: Partial<import("../src/d2m/actions/create-room")>, createSpace?: Partial<import("../src/d2m/actions/create-space")>, headers?: any}} [options]
|
||||
*/
|
||||
test(method, inputUrl, options = {}) {
|
||||
const url = new URL(inputUrl, "http://a")
|
||||
|
@ -80,6 +80,7 @@ class Router {
|
|||
params: options.params,
|
||||
snow: options.snow,
|
||||
createRoom: options.createRoom,
|
||||
createSpace: options.createSpace,
|
||||
sessions: {
|
||||
h3: {
|
||||
id: "h3",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue