Fix references from moving all those files

This commit is contained in:
Cadence Ember 2024-09-12 17:11:35 +12:00
parent 4247a3114a
commit 915c34646a
22 changed files with 67 additions and 59 deletions

2
.gitignore vendored
View file

@ -2,6 +2,6 @@ node_modules
config.js config.js
registration.yaml registration.yaml
coverage coverage
db/ooye.db* src/db/ooye.db*
test/res/* test/res/*
!test/res/lottie* !test/res/lottie*

View file

@ -4,7 +4,7 @@ const mixin = require("@cloudrac3r/mixin-deep")
const {channelToKState, _convertNameAndTopic} = require("./create-room") const {channelToKState, _convertNameAndTopic} = require("./create-room")
const {kstateStripConditionals} = require("../../matrix/kstate") const {kstateStripConditionals} = require("../../matrix/kstate")
const {test} = require("supertape") const {test} = require("supertape")
const testData = require("../../test/data") const testData = require("../../../test/data")
const passthrough = require("../../passthrough") const passthrough = require("../../passthrough")
const {db} = passthrough const {db} = passthrough

View file

@ -4,7 +4,7 @@ const mixin = require("@cloudrac3r/mixin-deep")
const {guildToKState, ensureSpace} = require("./create-space") const {guildToKState, ensureSpace} = require("./create-space")
const {kstateStripConditionals, kstateUploadMxc} = require("../../matrix/kstate") const {kstateStripConditionals, kstateUploadMxc} = require("../../matrix/kstate")
const {test} = require("supertape") const {test} = require("supertape")
const testData = require("../../test/data") const testData = require("../../../test/data")
const passthrough = require("../../passthrough") const passthrough = require("../../passthrough")
const {db} = passthrough const {db} = passthrough

View file

@ -1,6 +1,6 @@
const {_memberToStateContent} = require("./register-user") const {_memberToStateContent} = require("./register-user")
const {test} = require("supertape") const {test} = require("supertape")
const testData = require("../../test/data") const testData = require("../../../test/data")
test("member2state: without member nick or avatar", async t => { test("member2state: without member nick or avatar", async t => {
t.deepEqual( t.deepEqual(

View file

@ -1,6 +1,6 @@
const {test} = require("supertape") const {test} = require("supertape")
const {editToChanges} = require("./edit-to-changes") const {editToChanges} = require("./edit-to-changes")
const data = require("../../test/data") const data = require("../../../test/data")
const Ty = require("../../types") const Ty = require("../../types")
test("edit2changes: edit by webhook", async t => { test("edit2changes: edit by webhook", async t => {

View file

@ -2,7 +2,7 @@
const {test} = require("supertape") const {test} = require("supertape")
const {emojiToKey} = require("./emoji-to-key") const {emojiToKey} = require("./emoji-to-key")
const data = require("../../test/data") const data = require("../../../test/data")
const Ty = require("../../types") const Ty = require("../../types")
test("emoji2key: unicode emoji works", async t => { test("emoji2key: unicode emoji works", async t => {

View file

@ -1,6 +1,6 @@
const {test} = require("supertape") const {test} = require("supertape")
const {messageToEvent} = require("./message-to-event") const {messageToEvent} = require("./message-to-event")
const data = require("../../test/data") const data = require("../../../test/data")
const Ty = require("../../types") const Ty = require("../../types")
test("message2event embeds: nothing but a field", async t => { test("message2event embeds: nothing but a field", async t => {

View file

@ -1,6 +1,6 @@
const {test} = require("supertape") const {test} = require("supertape")
const {messageToEvent} = require("./message-to-event") const {messageToEvent} = require("./message-to-event")
const data = require("../../test/data") const data = require("../../../test/data")
const Ty = require("../../types") const Ty = require("../../types")
/** /**

View file

@ -1,6 +1,6 @@
const {test} = require("supertape") const {test} = require("supertape")
const {messageToEvent} = require("./message-to-event") const {messageToEvent} = require("./message-to-event")
const data = require("../../test/data") const data = require("../../../test/data")
const Ty = require("../../types") const Ty = require("../../types")
/** /**

View file

@ -1,5 +1,5 @@
const {test} = require("supertape") const {test} = require("supertape")
const data = require("../../test/data") const data = require("../../../test/data")
const {pinsToList} = require("./pins-to-list") const {pinsToList} = require("./pins-to-list")
test("pins2list: converts known IDs, ignores unknown IDs", t => { test("pins2list: converts known IDs, ignores unknown IDs", t => {

View file

@ -1,6 +1,6 @@
const {test} = require("supertape") const {test} = require("supertape")
const {threadToAnnouncement} = require("./thread-to-announcement") const {threadToAnnouncement} = require("./thread-to-announcement")
const data = require("../../test/data") const data = require("../../../test/data")
const Ty = require("../../types") const Ty = require("../../types")
/** /**

View file

@ -1,7 +1,7 @@
const {test} = require("supertape") const {test} = require("supertape")
const tryToCatch = require("try-to-catch") const tryToCatch = require("try-to-catch")
const assert = require("assert") const assert = require("assert")
const data = require("../../test/data") const data = require("../../../test/data")
const {userToSimName} = require("./user-to-mxid") const {userToSimName} = require("./user-to-mxid")
test("user2name: cannot create user for a webhook", async t => { test("user2name: cannot create user for a webhook", async t => {

View file

@ -10,7 +10,7 @@
*/ */
module.exports = async function(db) { module.exports = async function(db) {
const config = require("../../config") const config = require("../../../config")
const id = Buffer.from(config.discordToken.split(".")[0], "base64").toString() 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) db.prepare("UPDATE OR REPLACE sim SET user_id = ? WHERE user_id = '0'").run(id)
} }

View file

@ -0,0 +1,8 @@
BEGIN TRANSACTION;
CREATE TABLE "media_proxy" (
"permitted_hash" INTEGER NOT NULL,
PRIMARY KEY("permitted_hash")
) WITHOUT ROWID;
COMMIT;

View file

@ -1,7 +1,7 @@
// @ts-check // @ts-check
const {test} = require("supertape") const {test} = require("supertape")
const data = require("../test/data") const data = require("../../test/data")
const {db, select, from} = require("../passthrough") const {db, select, from} = require("../passthrough")

View file

@ -4,7 +4,7 @@ const assert = require("assert").strict
const util = require("util") const util = require("util")
const DiscordTypes = require("discord-api-types/v10") const DiscordTypes = require("discord-api-types/v10")
const {reg} = require("../matrix/read-registration") const {reg} = require("../matrix/read-registration")
const {addbot} = require("../addbot") const {addbot} = require("../../addbot")
const {discord, sync, db, select} = require("../passthrough") const {discord, sync, db, select} = require("../passthrough")
/** @type {import("../matrix/api")}) */ /** @type {import("../matrix/api")}) */
@ -12,7 +12,7 @@ const api = sync.require("../matrix/api")
/** @type {import("../matrix/file")} */ /** @type {import("../matrix/file")} */
const file = sync.require("../matrix/file") const file = sync.require("../matrix/file")
/** @type {import("../m2d/converters/utils")} */ /** @type {import("../m2d/converters/utils")} */
const mxUtils = sync.require("../matrix/utils") const mxUtils = sync.require("../m2d/converters/utils")
/** @type {import("../d2m/actions/create-space")} */ /** @type {import("../d2m/actions/create-space")} */
const createSpace = sync.require("../d2m/actions/create-space") const createSpace = sync.require("../d2m/actions/create-space")
/** @type {import("./utils")} */ /** @type {import("./utils")} */

View file

@ -2,7 +2,7 @@
const DiscordTypes = require("discord-api-types/v10") const DiscordTypes = require("discord-api-types/v10")
const {discord, sync, db, select} = require("../passthrough") const {discord, sync, db, select} = require("../passthrough")
const {id} = require("../addbot") const {id} = require("../../addbot")
const matrixInfo = sync.require("./interactions/matrix-info.js") const matrixInfo = sync.require("./interactions/matrix-info.js")
const invite = sync.require("./interactions/invite.js") const invite = sync.require("./interactions/invite.js")

View file

@ -1,6 +1,6 @@
const DiscordTypes = require("discord-api-types/v10") const DiscordTypes = require("discord-api-types/v10")
const {test} = require("supertape") const {test} = require("supertape")
const data = require("../test/data") const data = require("../../test/data")
const utils = require("./utils") const utils = require("./utils")
test("is webhook message: identifies bot interaction response as not a message", t => { test("is webhook message: identifies bot interaction response as not a message", t => {

View file

@ -3,7 +3,7 @@ const fs = require("fs")
const {test} = require("supertape") const {test} = require("supertape")
const {eventToMessage} = require("./event-to-message") const {eventToMessage} = require("./event-to-message")
const {convertImageStream} = require("./emoji-sheet") const {convertImageStream} = require("./emoji-sheet")
const data = require("../../test/data") const data = require("../../../test/data")
const {MatrixServerError} = require("../../matrix/mreq") const {MatrixServerError} = require("../../matrix/mreq")
const {select, discord} = require("../../passthrough") const {select, discord} = require("../../passthrough")

View file

@ -2,12 +2,12 @@
const repl = require("repl") const repl = require("repl")
const util = require("util") const util = require("util")
const {addbot} = require("./addbot") const {addbot} = require("../addbot")
const passthrough = require("./passthrough") const passthrough = require("./passthrough")
const {discord, config, sync, db} = 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 createSpace = sync.require("./d2m/actions/create-space")
const createRoom = sync.require("./d2m/actions/create-room") const createRoom = sync.require("./d2m/actions/create-room")
const registerUser = sync.require("./d2m/actions/register-user") const registerUser = sync.require("./d2m/actions/register-user")

View file

@ -1,32 +1,32 @@
// @ts-check // @ts-check
const sqlite = require("better-sqlite3") const sqlite = require("better-sqlite3")
const migrate = require("./db/migrate") const migrate = require("./src/db/migrate")
const HeatSync = require("heatsync") const HeatSync = require("heatsync")
const config = require("./config") const config = require("./config")
const passthrough = require("./passthrough") const passthrough = require("./src/passthrough")
const db = new sqlite("db/ooye.db") const db = new sqlite("src/db/ooye.db")
/** @type {import("heatsync").default} */ // @ts-ignore /** @type {import("heatsync").default} */ // @ts-ignore
const sync = new HeatSync() const sync = new HeatSync()
Object.assign(passthrough, {config, sync, db}) 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") const discord = new DiscordClient(config.discordToken, "full")
passthrough.discord = discord passthrough.discord = discord
const {as} = require("./matrix/appservice") const {as} = require("./src/matrix/appservice")
passthrough.as = as passthrough.as = as
const orm = sync.require("./db/orm") const orm = sync.require("./src/db/orm")
passthrough.from = orm.from passthrough.from = orm.from
passthrough.select = orm.select passthrough.select = orm.select
const power = require("./matrix/power.js") const power = require("./src/matrix/power.js")
sync.require("./m2d/event-dispatcher") sync.require("./src/m2d/event-dispatcher")
;(async () => { ;(async () => {
await migrate.migrate(db) await migrate.migrate(db)
@ -34,5 +34,5 @@ sync.require("./m2d/event-dispatcher")
console.log("Discord gateway started") console.log("Discord gateway started")
await power.applyPower() await power.applyPower()
require("./stdin") require("./src/stdin")
})() })()

View file

@ -4,7 +4,7 @@ const fs = require("fs")
const {join} = require("path") const {join} = require("path")
const stp = require("stream").promises const stp = require("stream").promises
const sqlite = require("better-sqlite3") const sqlite = require("better-sqlite3")
const migrate = require("../db/migrate") const migrate = require("../src/db/migrate")
const HeatSync = require("heatsync") const HeatSync = require("heatsync")
const {test} = require("supertape") const {test} = require("supertape")
const data = require("./data") const data = require("./data")
@ -14,10 +14,10 @@ const fetch = require("node-fetch")
const {green} = require("colorette") const {green} = require("colorette")
const config = require("../config") const config = require("../config")
const passthrough = require("../passthrough") const passthrough = require("../src/passthrough")
const db = new sqlite(":memory:") 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_origin = "https://matrix.cadence.moe" // so that tests will pass even when hard-coded
reg.ooye.server_name = "cadence.moe" reg.ooye.server_name = "cadence.moe"
reg.id = "baby" // don't actually take authenticated actions on the server 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 }) 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.from = orm.from
passthrough.select = orm.select passthrough.select = orm.select
const file = sync.require("../matrix/file") const file = sync.require("../src/matrix/file")
/* c8 ignore next */ /* c8 ignore next */
file._actuallyUploadDiscordFileToMxc = function(url, res) { throw new Error(`Not allowed to upload files during testing.\nURL: ${url}`) } 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")) db.exec(fs.readFileSync(join(__dirname, "ooye-test-data.sql"), "utf8"))
require("../db/orm.test") require("../src/db/orm.test")
require("../discord/utils.test") require("../src/discord/utils.test")
require("../matrix/kstate.test") require("../src/matrix/kstate.test")
require("../matrix/api.test") require("../src/matrix/api.test")
require("../matrix/file.test") require("../src/matrix/file.test")
//require("../matrix/power.test") require("../src/matrix/power.test")
require("../matrix/read-registration.test") require("../src/matrix/read-registration.test")
require("../matrix/txnid.test") require("../src/matrix/txnid.test")
require("../d2m/actions/create-room.test") require("../src/d2m/actions/create-room.test")
require("../d2m/actions/create-space.test") require("../src/d2m/actions/create-space.test")
require("../d2m/actions/register-user.test") require("../src/d2m/actions/register-user.test")
require("../d2m/converters/edit-to-changes.test") require("../src/d2m/converters/edit-to-changes.test")
require("../d2m/converters/emoji-to-key.test") require("../src/d2m/converters/emoji-to-key.test")
require("../d2m/converters/lottie.test") require("../src/d2m/converters/lottie.test")
require("../d2m/converters/message-to-event.test") require("../src/d2m/converters/message-to-event.test")
require("../d2m/converters/message-to-event.embeds.test") require("../src/d2m/converters/message-to-event.embeds.test")
require("../d2m/converters/message-to-event.pk.test") require("../src/d2m/converters/message-to-event.pk.test")
require("../d2m/converters/pins-to-list.test") require("../src/d2m/converters/pins-to-list.test")
require("../d2m/converters/remove-reaction.test") require("../src/d2m/converters/remove-reaction.test")
require("../d2m/converters/thread-to-announcement.test") require("../src/d2m/converters/thread-to-announcement.test")
require("../d2m/converters/user-to-mxid.test") require("../src/d2m/converters/user-to-mxid.test")
require("../m2d/converters/event-to-message.test") require("../src/m2d/converters/event-to-message.test")
require("../m2d/converters/utils.test") require("../src/m2d/converters/utils.test")
require("../m2d/converters/emoji-sheet.test") require("../src/m2d/converters/emoji-sheet.test")
})() })()