2023-08-15 05:20:31 +00:00
|
|
|
async function editMessage() {
|
|
|
|
// Action time!
|
2023-07-28 05:05:13 +00:00
|
|
|
|
|
|
|
// 1. Replace all the things.
|
|
|
|
|
|
|
|
|
|
|
|
// 2. Redact all the things.
|
|
|
|
|
|
|
|
// 3. Send all the things.
|
|
|
|
|
|
|
|
// old code lies here
|
2023-08-17 00:35:34 +00:00
|
|
|
let eventPart = 0 // TODO: what to do about eventPart when editing? probably just need to make sure that exactly 1 value of '0' remains in the database?
|
2023-07-28 05:05:13 +00:00
|
|
|
for (const event of events) {
|
|
|
|
const eventType = event.$type
|
|
|
|
/** @type {Pick<typeof event, Exclude<keyof event, "$type">> & { $type?: string }} */
|
|
|
|
const eventWithoutType = {...event}
|
|
|
|
delete eventWithoutType.$type
|
|
|
|
|
|
|
|
const eventID = await api.sendEvent(roomID, eventType, event, senderMxid)
|
|
|
|
db.prepare("INSERT INTO event_message (event_id, message_id, channel_id, part, source) VALUES (?, ?, ?, ?, 1)").run(eventID, message.id, message.channel_id, eventPart) // source 1 = discord
|
|
|
|
|
|
|
|
eventPart = 1 // TODO: use more intelligent algorithm to determine whether primary or supporting
|
|
|
|
eventIDs.push(eventID)
|
|
|
|
}
|
|
|
|
|
|
|
|
return eventIDs
|
|
|
|
|
2023-08-15 05:20:31 +00:00
|
|
|
{eventsToReplace, eventsToRedact, eventsToSend}
|