Compare commits
2 commits
9c3f1abd3a
...
762e48230c
Author | SHA1 | Date | |
---|---|---|---|
762e48230c | |||
a542bbdca7 |
4 changed files with 17 additions and 10 deletions
|
@ -36,7 +36,7 @@ async function createSim(user) {
|
|||
await api.register(localpart)
|
||||
} catch (e) {
|
||||
// If user creation fails, manually undo the database change. Still isn't perfect, but should help.
|
||||
// (A transaction would be preferable, but I don't think it's safe to leave transaction open across event loop ticks.)
|
||||
// (I would prefer a transaction, but it's not safe to leave transactions open across event loop ticks.)
|
||||
db.prepare("DELETE FROM sim WHERE user_id = ?").run(user.id)
|
||||
throw e
|
||||
}
|
||||
|
|
6
package-lock.json
generated
6
package-lock.json
generated
|
@ -13,7 +13,7 @@
|
|||
"better-sqlite3": "^9.0.0",
|
||||
"chunk-text": "^2.0.1",
|
||||
"cloudstorm": "^0.9.0",
|
||||
"discord-markdown": "git+https://git.sr.ht/~cadence/nodejs-discord-markdown#abc56d544072a1dc5624adfea455b0e902adf7b3",
|
||||
"discord-markdown": "git+https://git.sr.ht/~cadence/nodejs-discord-markdown#de519353668c87ecc8c543e9749093481bc72ff8",
|
||||
"entities": "^4.5.0",
|
||||
"giframe": "github:cloudrac3r/giframe#v0.4.1",
|
||||
"heatsync": "^2.4.1",
|
||||
|
@ -1058,8 +1058,8 @@
|
|||
"integrity": "sha512-5BELXTsv7becqVHrD81nZrqT4oEyXXWBwbsO/kwDDu6X3u19VV1tYDB5I5vaVAK+c1chcDeheI9zACBLm41LiQ=="
|
||||
},
|
||||
"node_modules/discord-markdown": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "git+https://git.sr.ht/~cadence/nodejs-discord-markdown#abc56d544072a1dc5624adfea455b0e902adf7b3",
|
||||
"version": "2.5.1",
|
||||
"resolved": "git+https://git.sr.ht/~cadence/nodejs-discord-markdown#de519353668c87ecc8c543e9749093481bc72ff8",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"simple-markdown": "^0.7.2"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
"better-sqlite3": "^9.0.0",
|
||||
"chunk-text": "^2.0.1",
|
||||
"cloudstorm": "^0.9.0",
|
||||
"discord-markdown": "git+https://git.sr.ht/~cadence/nodejs-discord-markdown#abc56d544072a1dc5624adfea455b0e902adf7b3",
|
||||
"discord-markdown": "git+https://git.sr.ht/~cadence/nodejs-discord-markdown#de519353668c87ecc8c543e9749093481bc72ff8",
|
||||
"entities": "^4.5.0",
|
||||
"giframe": "github:cloudrac3r/giframe#v0.4.1",
|
||||
"heatsync": "^2.4.1",
|
||||
|
|
|
@ -67,6 +67,18 @@ async function uploadAutoEmoji(guild, name, filename) {
|
|||
|
||||
console.log("✅ Database is ready...")
|
||||
|
||||
// ensure appservice bot user is registered...
|
||||
try {
|
||||
await api.register(reg.sender_localpart)
|
||||
} catch (e) {
|
||||
if (e.data?.error !== "Internal server error") throw e // "Internal server error" is the only OK error because Synapse says this if you try to register the same username twice.
|
||||
}
|
||||
|
||||
// upload initial images...
|
||||
const avatarUrl = await file.uploadDiscordFileToMxc("https://cadence.moe/friends/out_of_your_element.png")
|
||||
|
||||
console.log("✅ Matrix appservice login works...")
|
||||
|
||||
// upload the L1 L2 emojis to some guild
|
||||
const emojis = db.prepare("SELECT name FROM auto_emoji WHERE name = 'L1' OR name = 'L2'").pluck().all()
|
||||
if (emojis.length !== 2) {
|
||||
|
@ -104,11 +116,6 @@ async function uploadAutoEmoji(guild, name, filename) {
|
|||
}
|
||||
console.log("✅ Emojis are ready...")
|
||||
|
||||
// ensure homeserver well-known is valid and returns reg.ooye.server_name...
|
||||
|
||||
// upload initial images...
|
||||
const avatarUrl = await file.uploadDiscordFileToMxc("https://cadence.moe/friends/out_of_your_element.png")
|
||||
|
||||
// set profile data on discord...
|
||||
const avatarImageBuffer = await fetch("https://cadence.moe/friends/out_of_your_element.png").then(res => res.arrayBuffer())
|
||||
await discord.snow.user.updateSelf({avatar: "data:image/png;base64," + Buffer.from(avatarImageBuffer).toString("base64")})
|
||||
|
|
Loading…
Reference in a new issue