Finish moving from SQL to New Funny ORM
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// @ts-check
|
||||
|
||||
const passthrough = require("../../passthrough")
|
||||
const { sync, db } = passthrough
|
||||
const {sync, db, select} = passthrough
|
||||
/** @type {import("../../matrix/api")} */
|
||||
const api = sync.require("../../matrix/api")
|
||||
|
||||
@@ -9,13 +9,10 @@ const api = sync.require("../../matrix/api")
|
||||
* @param {import("discord-api-types/v10").GatewayMessageDeleteDispatchData} data
|
||||
*/
|
||||
async function deleteMessage(data) {
|
||||
/** @type {string?} */
|
||||
const roomID = db.prepare("SELECT room_id FROM channel_room WHERE channel_id = ?").pluck().get(data.channel_id)
|
||||
const roomID = select("channel_room", "room_id", "WHERE channel_id = ?").pluck().get(data.channel_id)
|
||||
if (!roomID) return
|
||||
|
||||
/** @type {string[]} */
|
||||
const eventsToRedact = db.prepare("SELECT event_id FROM event_message WHERE message_id = ?").pluck().all(data.id)
|
||||
|
||||
const eventsToRedact = select("event_message", "event_id", "WHERE message_id = ?").pluck().all(data.id)
|
||||
for (const eventID of eventsToRedact) {
|
||||
// Unfortunately, we can't specify a sender to do the redaction as, unless we find out that info via the audit logs
|
||||
await api.redactEvent(roomID, eventID)
|
||||
|
Reference in New Issue
Block a user