diff --git a/d2m/actions/register-user.js b/d2m/actions/register-user.js
index ef6045a..1d1eb3d 100644
--- a/d2m/actions/register-user.js
+++ b/d2m/actions/register-user.js
@@ -20,7 +20,7 @@ const userToMxid = sync.require("../converters/user-to-mxid")
async function createSim(user) {
// Choose sim name
const simName = userToMxid.userToSimName(user)
- const localpart = reg.ooye.namespace_prefix + simName
+ const localpart = reg.namespace_prefix + simName
const mxid = "@" + localpart + ":cadence.moe"
// Save chosen name in the database forever
diff --git a/d2m/converters/message-to-event.js b/d2m/converters/message-to-event.js
index 49a387a..300d154 100644
--- a/d2m/converters/message-to-event.js
+++ b/d2m/converters/message-to-event.js
@@ -2,7 +2,6 @@
const assert = require("assert").strict
const markdown = require("discord-markdown")
-const pb = require("prettier-bytes")
const DiscordTypes = require("discord-api-types/v10")
const passthrough = require("../../passthrough")
@@ -185,24 +184,8 @@ async function messageToEvent(message, guild, api) {
// Then attachments
const attachmentEvents = await Promise.all(message.attachments.map(async attachment => {
- const emoji =
- attachment.content_type?.startsWith("image/jp") ? "📸"
- : attachment.content_type?.startsWith("image/") ? "🖼️"
- : attachment.content_type?.startsWith("video/") ? "🎞️"
- : attachment.content_type?.startsWith("text/") ? "📝"
- : attachment.content_type?.startsWith("audio/") ? "🎶"
- : "📄"
- // for large files, always link them instead of uploading so I don't use up all the space in the content repo
- if (attachment.size > reg.ooye.max_file_size) {
- return {
- $type: "m.room.message",
- "m.mentions": mentions,
- msgtype: "m.text",
- body: `${emoji} Uploaded file: ${attachment.url} (${pb(attachment.size)})`,
- format: "org.matrix.custom.html",
- formatted_body: `${emoji} Uploaded file: ${attachment.filename} (${pb(attachment.size)})`
- }
- } else if (attachment.content_type?.startsWith("image/") && attachment.width && attachment.height) {
+ // TODO: handle large files differently - link them instead of uploading
+ if (attachment.content_type?.startsWith("image/") && attachment.width && attachment.height) {
return {
$type: "m.room.message",
"m.mentions": mentions,
@@ -223,7 +206,7 @@ async function messageToEvent(message, guild, api) {
$type: "m.room.message",
"m.mentions": mentions,
msgtype: "m.text",
- body: `Unsupported attachment:\n${JSON.stringify(attachment, null, 2)}\n${attachment.url}`
+ body: "Unsupported attachment:\n" + JSON.stringify(attachment, null, 2)
}
}
}))
diff --git a/d2m/converters/message-to-event.test.js b/d2m/converters/message-to-event.test.js
index 17079e5..58093ca 100644
--- a/d2m/converters/message-to-event.test.js
+++ b/d2m/converters/message-to-event.test.js
@@ -258,29 +258,4 @@ test("message2event: simple written @mention for matrix user", async t => {
}])
})
-test("message2event: very large attachment is linked instead of being uploaded", async t => {
- const events = await messageToEvent({
- content: "hey",
- attachments: [{
- filename: "hey.jpg",
- url: "https://discord.com/404/hey.jpg",
- content_type: "application/i-made-it-up",
- size: 100e6
- }]
- })
- t.deepEqual(events, [{
- $type: "m.room.message",
- "m.mentions": {},
- msgtype: "m.text",
- body: "hey"
- }, {
- $type: "m.room.message",
- "m.mentions": {},
- msgtype: "m.text",
- body: "📄 Uploaded file: https://discord.com/404/hey.jpg (100 MB)",
- format: "org.matrix.custom.html",
- formatted_body: '📄 Uploaded file: hey.jpg (100 MB)'
- }])
-})
-
// TODO: read "edits of replies" in the spec
diff --git a/db/ooye.db b/db/ooye.db
index a22816b..8856af2 100644
Binary files a/db/ooye.db and b/db/ooye.db differ
diff --git a/matrix/api.js b/matrix/api.js
index 7f9d74e..ed9980b 100644
--- a/matrix/api.js
+++ b/matrix/api.js
@@ -110,7 +110,7 @@ async function sendState(roomID, type, stateKey, content, mxid) {
}
async function sendEvent(roomID, type, content, mxid) {
- console.log(`[api] event ${type} to ${roomID} as ${mxid || "default sim"}`)
+ console.log(`[api] event to ${roomID} as ${mxid || "default sim"}`)
/** @type {Ty.R.EventSent} */
const root = await mreq.mreq("PUT", path(`/client/v3/rooms/${roomID}/send/${type}/${makeTxnId.makeTxnId()}`, mxid), content)
return root.event_id
diff --git a/matrix/read-registration.test.js b/matrix/read-registration.test.js
index d402cfb..c5b3ac8 100644
--- a/matrix/read-registration.test.js
+++ b/matrix/read-registration.test.js
@@ -2,7 +2,7 @@ const {test} = require("supertape")
const reg = require("./read-registration")
test("reg: has necessary parameters", t => {
- const propertiesToCheck = ["sender_localpart", "id", "as_token", "ooye"]
+ const propertiesToCheck = ["sender_localpart", "id", "as_token", "namespace_prefix"]
t.deepEqual(
propertiesToCheck.filter(p => p in reg),
propertiesToCheck
diff --git a/package-lock.json b/package-lock.json
index 13b6799..7dcde49 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -18,7 +18,6 @@
"matrix-js-sdk": "^24.1.0",
"mixin-deep": "^2.0.1",
"node-fetch": "^2.6.7",
- "prettier-bytes": "^1.0.4",
"snowtransfer": "^0.8.0",
"try-to-catch": "^3.0.1"
},
@@ -2100,11 +2099,6 @@
"node": ">=10"
}
},
- "node_modules/prettier-bytes": {
- "version": "1.0.4",
- "resolved": "https://registry.npmjs.org/prettier-bytes/-/prettier-bytes-1.0.4.tgz",
- "integrity": "sha512-dLbWOa4xBn+qeWeIF60qRoB6Pk2jX5P3DIVgOQyMyvBpu931Q+8dXz8X0snJiFkQdohDDLnZQECjzsAj75hgZQ=="
- },
"node_modules/pretty-format": {
"version": "29.5.0",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.5.0.tgz",
@@ -2324,9 +2318,9 @@
}
},
"node_modules/semver": {
- "version": "7.5.4",
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
- "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==",
+ "version": "7.5.0",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.0.tgz",
+ "integrity": "sha512-+XC0AD/R7Q2mPSRuy2Id0+CGTZ98+8f+KvwirxOKIEyid+XSx6HbC63p+O4IndTHuX5Z+JxQ0TghCkO5Cg/2HA==",
"dependencies": {
"lru-cache": "^6.0.0"
},
diff --git a/package.json b/package.json
index 951089b..8604330 100644
--- a/package.json
+++ b/package.json
@@ -24,7 +24,6 @@
"matrix-js-sdk": "^24.1.0",
"mixin-deep": "^2.0.1",
"node-fetch": "^2.6.7",
- "prettier-bytes": "^1.0.4",
"snowtransfer": "^0.8.0",
"try-to-catch": "^3.0.1"
},
diff --git a/types.d.ts b/types.d.ts
index eeb4b75..3ed3975 100644
--- a/types.d.ts
+++ b/types.d.ts
@@ -4,6 +4,7 @@ export type AppServiceRegistrationConfig = {
hs_token: string
url: string
sender_localpart: string
+ namespace_prefix: string
namespaces: {
users: {
exclusive: boolean
@@ -16,10 +17,6 @@ export type AppServiceRegistrationConfig = {
}
protocols: [string]
rate_limited: boolean
- ooye: {
- namespace_prefix: string
- max_file_size: number
- }
}
export type WebhookCreds = {