Fix references from moving all those files
This commit is contained in:
parent
4247a3114a
commit
915c34646a
22 changed files with 67 additions and 59 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,6 +2,6 @@ node_modules
|
|||
config.js
|
||||
registration.yaml
|
||||
coverage
|
||||
db/ooye.db*
|
||||
src/db/ooye.db*
|
||||
test/res/*
|
||||
!test/res/lottie*
|
||||
|
|
|
@ -4,7 +4,7 @@ const mixin = require("@cloudrac3r/mixin-deep")
|
|||
const {channelToKState, _convertNameAndTopic} = require("./create-room")
|
||||
const {kstateStripConditionals} = require("../../matrix/kstate")
|
||||
const {test} = require("supertape")
|
||||
const testData = require("../../test/data")
|
||||
const testData = require("../../../test/data")
|
||||
|
||||
const passthrough = require("../../passthrough")
|
||||
const {db} = passthrough
|
||||
|
|
|
@ -4,7 +4,7 @@ const mixin = require("@cloudrac3r/mixin-deep")
|
|||
const {guildToKState, ensureSpace} = require("./create-space")
|
||||
const {kstateStripConditionals, kstateUploadMxc} = require("../../matrix/kstate")
|
||||
const {test} = require("supertape")
|
||||
const testData = require("../../test/data")
|
||||
const testData = require("../../../test/data")
|
||||
|
||||
const passthrough = require("../../passthrough")
|
||||
const {db} = passthrough
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const {_memberToStateContent} = require("./register-user")
|
||||
const {test} = require("supertape")
|
||||
const testData = require("../../test/data")
|
||||
const testData = require("../../../test/data")
|
||||
|
||||
test("member2state: without member nick or avatar", async t => {
|
||||
t.deepEqual(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const {test} = require("supertape")
|
||||
const {editToChanges} = require("./edit-to-changes")
|
||||
const data = require("../../test/data")
|
||||
const data = require("../../../test/data")
|
||||
const Ty = require("../../types")
|
||||
|
||||
test("edit2changes: edit by webhook", async t => {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const {test} = require("supertape")
|
||||
const {emojiToKey} = require("./emoji-to-key")
|
||||
const data = require("../../test/data")
|
||||
const data = require("../../../test/data")
|
||||
const Ty = require("../../types")
|
||||
|
||||
test("emoji2key: unicode emoji works", async t => {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const {test} = require("supertape")
|
||||
const {messageToEvent} = require("./message-to-event")
|
||||
const data = require("../../test/data")
|
||||
const data = require("../../../test/data")
|
||||
const Ty = require("../../types")
|
||||
|
||||
test("message2event embeds: nothing but a field", async t => {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const {test} = require("supertape")
|
||||
const {messageToEvent} = require("./message-to-event")
|
||||
const data = require("../../test/data")
|
||||
const data = require("../../../test/data")
|
||||
const Ty = require("../../types")
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const {test} = require("supertape")
|
||||
const {messageToEvent} = require("./message-to-event")
|
||||
const data = require("../../test/data")
|
||||
const data = require("../../../test/data")
|
||||
const Ty = require("../../types")
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const {test} = require("supertape")
|
||||
const data = require("../../test/data")
|
||||
const data = require("../../../test/data")
|
||||
const {pinsToList} = require("./pins-to-list")
|
||||
|
||||
test("pins2list: converts known IDs, ignores unknown IDs", t => {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const {test} = require("supertape")
|
||||
const {threadToAnnouncement} = require("./thread-to-announcement")
|
||||
const data = require("../../test/data")
|
||||
const data = require("../../../test/data")
|
||||
const Ty = require("../../types")
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const {test} = require("supertape")
|
||||
const tryToCatch = require("try-to-catch")
|
||||
const assert = require("assert")
|
||||
const data = require("../../test/data")
|
||||
const data = require("../../../test/data")
|
||||
const {userToSimName} = require("./user-to-mxid")
|
||||
|
||||
test("user2name: cannot create user for a webhook", async t => {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*/
|
||||
|
||||
module.exports = async function(db) {
|
||||
const config = require("../../config")
|
||||
const config = require("../../../config")
|
||||
const id = Buffer.from(config.discordToken.split(".")[0], "base64").toString()
|
||||
db.prepare("UPDATE OR REPLACE sim SET user_id = ? WHERE user_id = '0'").run(id)
|
||||
}
|
||||
|
|
8
src/db/migrations/0013-media-proxy.sql
Normal file
8
src/db/migrations/0013-media-proxy.sql
Normal file
|
@ -0,0 +1,8 @@
|
|||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE "media_proxy" (
|
||||
"permitted_hash" INTEGER NOT NULL,
|
||||
PRIMARY KEY("permitted_hash")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
COMMIT;
|
|
@ -1,7 +1,7 @@
|
|||
// @ts-check
|
||||
|
||||
const {test} = require("supertape")
|
||||
const data = require("../test/data")
|
||||
const data = require("../../test/data")
|
||||
|
||||
const {db, select, from} = require("../passthrough")
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ const assert = require("assert").strict
|
|||
const util = require("util")
|
||||
const DiscordTypes = require("discord-api-types/v10")
|
||||
const {reg} = require("../matrix/read-registration")
|
||||
const {addbot} = require("../addbot")
|
||||
const {addbot} = require("../../addbot")
|
||||
|
||||
const {discord, sync, db, select} = require("../passthrough")
|
||||
/** @type {import("../matrix/api")}) */
|
||||
|
@ -12,7 +12,7 @@ const api = sync.require("../matrix/api")
|
|||
/** @type {import("../matrix/file")} */
|
||||
const file = sync.require("../matrix/file")
|
||||
/** @type {import("../m2d/converters/utils")} */
|
||||
const mxUtils = sync.require("../matrix/utils")
|
||||
const mxUtils = sync.require("../m2d/converters/utils")
|
||||
/** @type {import("../d2m/actions/create-space")} */
|
||||
const createSpace = sync.require("../d2m/actions/create-space")
|
||||
/** @type {import("./utils")} */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const DiscordTypes = require("discord-api-types/v10")
|
||||
const {discord, sync, db, select} = require("../passthrough")
|
||||
const {id} = require("../addbot")
|
||||
const {id} = require("../../addbot")
|
||||
|
||||
const matrixInfo = sync.require("./interactions/matrix-info.js")
|
||||
const invite = sync.require("./interactions/invite.js")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const DiscordTypes = require("discord-api-types/v10")
|
||||
const {test} = require("supertape")
|
||||
const data = require("../test/data")
|
||||
const data = require("../../test/data")
|
||||
const utils = require("./utils")
|
||||
|
||||
test("is webhook message: identifies bot interaction response as not a message", t => {
|
||||
|
|
|
@ -3,7 +3,7 @@ const fs = require("fs")
|
|||
const {test} = require("supertape")
|
||||
const {eventToMessage} = require("./event-to-message")
|
||||
const {convertImageStream} = require("./emoji-sheet")
|
||||
const data = require("../../test/data")
|
||||
const data = require("../../../test/data")
|
||||
const {MatrixServerError} = require("../../matrix/mreq")
|
||||
const {select, discord} = require("../../passthrough")
|
||||
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
const repl = require("repl")
|
||||
const util = require("util")
|
||||
const {addbot} = require("./addbot")
|
||||
const {addbot} = require("../addbot")
|
||||
|
||||
const passthrough = require("./passthrough")
|
||||
const {discord, config, sync, db} = passthrough
|
||||
|
||||
const data = sync.require("./test/data")
|
||||
const data = sync.require("../test/data")
|
||||
const createSpace = sync.require("./d2m/actions/create-space")
|
||||
const createRoom = sync.require("./d2m/actions/create-room")
|
||||
const registerUser = sync.require("./d2m/actions/register-user")
|
||||
|
|
18
start.js
18
start.js
|
@ -1,32 +1,32 @@
|
|||
// @ts-check
|
||||
|
||||
const sqlite = require("better-sqlite3")
|
||||
const migrate = require("./db/migrate")
|
||||
const migrate = require("./src/db/migrate")
|
||||
const HeatSync = require("heatsync")
|
||||
|
||||
const config = require("./config")
|
||||
const passthrough = require("./passthrough")
|
||||
const db = new sqlite("db/ooye.db")
|
||||
const passthrough = require("./src/passthrough")
|
||||
const db = new sqlite("src/db/ooye.db")
|
||||
|
||||
/** @type {import("heatsync").default} */ // @ts-ignore
|
||||
const sync = new HeatSync()
|
||||
|
||||
Object.assign(passthrough, {config, sync, db})
|
||||
|
||||
const DiscordClient = require("./d2m/discord-client")
|
||||
const DiscordClient = require("./src/d2m/discord-client")
|
||||
|
||||
const discord = new DiscordClient(config.discordToken, "full")
|
||||
passthrough.discord = discord
|
||||
|
||||
const {as} = require("./matrix/appservice")
|
||||
const {as} = require("./src/matrix/appservice")
|
||||
passthrough.as = as
|
||||
|
||||
const orm = sync.require("./db/orm")
|
||||
const orm = sync.require("./src/db/orm")
|
||||
passthrough.from = orm.from
|
||||
passthrough.select = orm.select
|
||||
|
||||
const power = require("./matrix/power.js")
|
||||
sync.require("./m2d/event-dispatcher")
|
||||
const power = require("./src/matrix/power.js")
|
||||
sync.require("./src/m2d/event-dispatcher")
|
||||
|
||||
;(async () => {
|
||||
await migrate.migrate(db)
|
||||
|
@ -34,5 +34,5 @@ sync.require("./m2d/event-dispatcher")
|
|||
console.log("Discord gateway started")
|
||||
await power.applyPower()
|
||||
|
||||
require("./stdin")
|
||||
require("./src/stdin")
|
||||
})()
|
||||
|
|
58
test/test.js
58
test/test.js
|
@ -4,7 +4,7 @@ const fs = require("fs")
|
|||
const {join} = require("path")
|
||||
const stp = require("stream").promises
|
||||
const sqlite = require("better-sqlite3")
|
||||
const migrate = require("../db/migrate")
|
||||
const migrate = require("../src/db/migrate")
|
||||
const HeatSync = require("heatsync")
|
||||
const {test} = require("supertape")
|
||||
const data = require("./data")
|
||||
|
@ -14,10 +14,10 @@ const fetch = require("node-fetch")
|
|||
const {green} = require("colorette")
|
||||
|
||||
const config = require("../config")
|
||||
const passthrough = require("../passthrough")
|
||||
const passthrough = require("../src/passthrough")
|
||||
const db = new sqlite(":memory:")
|
||||
|
||||
const {reg} = require("../matrix/read-registration")
|
||||
const {reg} = require("../src/matrix/read-registration")
|
||||
reg.ooye.server_origin = "https://matrix.cadence.moe" // so that tests will pass even when hard-coded
|
||||
reg.ooye.server_name = "cadence.moe"
|
||||
reg.id = "baby" // don't actually take authenticated actions on the server
|
||||
|
@ -48,11 +48,11 @@ const discord = {
|
|||
|
||||
Object.assign(passthrough, { discord, config, sync, db })
|
||||
|
||||
const orm = sync.require("../db/orm")
|
||||
const orm = sync.require("../src/db/orm")
|
||||
passthrough.from = orm.from
|
||||
passthrough.select = orm.select
|
||||
|
||||
const file = sync.require("../matrix/file")
|
||||
const file = sync.require("../src/matrix/file")
|
||||
/* c8 ignore next */
|
||||
file._actuallyUploadDiscordFileToMxc = function(url, res) { throw new Error(`Not allowed to upload files during testing.\nURL: ${url}`) }
|
||||
|
||||
|
@ -113,28 +113,28 @@ file._actuallyUploadDiscordFileToMxc = function(url, res) { throw new Error(`Not
|
|||
|
||||
db.exec(fs.readFileSync(join(__dirname, "ooye-test-data.sql"), "utf8"))
|
||||
|
||||
require("../db/orm.test")
|
||||
require("../discord/utils.test")
|
||||
require("../matrix/kstate.test")
|
||||
require("../matrix/api.test")
|
||||
require("../matrix/file.test")
|
||||
//require("../matrix/power.test")
|
||||
require("../matrix/read-registration.test")
|
||||
require("../matrix/txnid.test")
|
||||
require("../d2m/actions/create-room.test")
|
||||
require("../d2m/actions/create-space.test")
|
||||
require("../d2m/actions/register-user.test")
|
||||
require("../d2m/converters/edit-to-changes.test")
|
||||
require("../d2m/converters/emoji-to-key.test")
|
||||
require("../d2m/converters/lottie.test")
|
||||
require("../d2m/converters/message-to-event.test")
|
||||
require("../d2m/converters/message-to-event.embeds.test")
|
||||
require("../d2m/converters/message-to-event.pk.test")
|
||||
require("../d2m/converters/pins-to-list.test")
|
||||
require("../d2m/converters/remove-reaction.test")
|
||||
require("../d2m/converters/thread-to-announcement.test")
|
||||
require("../d2m/converters/user-to-mxid.test")
|
||||
require("../m2d/converters/event-to-message.test")
|
||||
require("../m2d/converters/utils.test")
|
||||
require("../m2d/converters/emoji-sheet.test")
|
||||
require("../src/db/orm.test")
|
||||
require("../src/discord/utils.test")
|
||||
require("../src/matrix/kstate.test")
|
||||
require("../src/matrix/api.test")
|
||||
require("../src/matrix/file.test")
|
||||
require("../src/matrix/power.test")
|
||||
require("../src/matrix/read-registration.test")
|
||||
require("../src/matrix/txnid.test")
|
||||
require("../src/d2m/actions/create-room.test")
|
||||
require("../src/d2m/actions/create-space.test")
|
||||
require("../src/d2m/actions/register-user.test")
|
||||
require("../src/d2m/converters/edit-to-changes.test")
|
||||
require("../src/d2m/converters/emoji-to-key.test")
|
||||
require("../src/d2m/converters/lottie.test")
|
||||
require("../src/d2m/converters/message-to-event.test")
|
||||
require("../src/d2m/converters/message-to-event.embeds.test")
|
||||
require("../src/d2m/converters/message-to-event.pk.test")
|
||||
require("../src/d2m/converters/pins-to-list.test")
|
||||
require("../src/d2m/converters/remove-reaction.test")
|
||||
require("../src/d2m/converters/thread-to-announcement.test")
|
||||
require("../src/d2m/converters/user-to-mxid.test")
|
||||
require("../src/m2d/converters/event-to-message.test")
|
||||
require("../src/m2d/converters/utils.test")
|
||||
require("../src/m2d/converters/emoji-sheet.test")
|
||||
})()
|
||||
|
|
Loading…
Reference in a new issue