Finish moving from SQL to New Funny ORM

This commit is contained in:
Cadence Ember 2023-09-18 22:51:59 +12:00
parent 4e1e590c3a
commit 79bd0254f0
19 changed files with 87 additions and 87 deletions

View file

@ -3,7 +3,7 @@
const assert = require("assert").strict
const passthrough = require("../../passthrough")
const { discord, sync, db } = passthrough
const {discord, sync, db, select} = passthrough
/** @type {import("../../matrix/api")} */
const api = sync.require("../../matrix/api")
/** @type {import("./register-user")} */
@ -17,7 +17,7 @@ const createRoom = sync.require("../actions/create-room")
async function addReaction(data) {
const user = data.member?.user
assert.ok(user && user.username)
const parentID = db.prepare("SELECT event_id FROM event_message WHERE message_id = ? AND part = 0").pluck().get(data.message_id) // 0 = primary
const parentID = select("event_message", "event_id", "WHERE message = ? AND part = 0").pluck().get(data.message_id) // 0 = primary
if (!parentID) return // Nothing can be done if the parent message was never bridged.
assert.equal(typeof parentID, "string")
const roomID = await createRoom.ensureRoom(data.channel_id)