feat/add-unlink-space-button #63
2 changed files with 6 additions and 15 deletions
|
|
@ -459,12 +459,12 @@ async function unbridgeDeletedChannel(channel, guildID) {
|
|||
const webhook = select("webhook", ["webhook_id", "webhook_token"], {channel_id: channel.id}).get()
|
||||
if (webhook) {
|
||||
await discord.snow.webhook.deleteWebhook(webhook.webhook_id, webhook.webhook_token)
|
||||
db.prepare("DELETE FROM webhook WHERE channel_id = ?").run(channel.id)
|
||||
await db.prepare("DELETE FROM webhook WHERE channel_id = ?").run(channel.id)
|
||||
}
|
||||
|
||||
// delete room from database
|
||||
db.prepare("DELETE FROM member_cache WHERE room_id = ?").run(roomID)
|
||||
db.prepare("DELETE FROM channel_room WHERE room_id = ? AND channel_id = ?").run(roomID, channel.id) // cascades to most other tables, like messages
|
||||
await db.prepare("DELETE FROM member_cache WHERE room_id = ?").run(roomID)
|
||||
await db.prepare("DELETE FROM channel_room WHERE room_id = ? AND channel_id = ?").run(roomID, channel.id) // cascades to most other tables, like messages
|
||||
|
||||
if (!botInRoom) return
|
||||
|
||||
|
|
|
|||
|
|
@ -274,15 +274,6 @@ as.router.post("/api/unlink-space", defineEventHandler(async event => {
|
|||
|
||||
for (const channel of linkedChannels) {
|
||||
await doRoomUnlink(event, channel.channel_id, guild_id)
|
||||
|
||||
// FIXME: probably fix the underlying issue instead:
|
||||
// If not waiting for ~1s, then the room is half unbridged:
|
||||
// the resources in the room is not properly cleaned up, meaning that the sim users
|
||||
// and the bridge user are not power demoted nor leave the room
|
||||
// The entry from the channel_room table is not deleted
|
||||
// After that, writing in the discord channel does nothing,
|
||||
// and writing in the matrix channel spawns an error for not finding guild_id
|
||||
await new Promise(r => setTimeout(r, 5000));
|
||||
}
|
||||
|
||||
const remainingLinkedChannels = select("channel_room", ["channel_id", "room_id", "name", "nick"], {guild_id: guild_id}).all()
|
||||
|
|
@ -293,10 +284,10 @@ as.router.post("/api/unlink-space", defineEventHandler(async event => {
|
|||
await api.setUserPower(spaceID, me, 0)
|
||||
await api.leaveRoom(spaceID)
|
||||
|
||||
db.prepare("DELETE FROM guild_space WHERE guild_id=? AND space_id=?").run(guild_id, spaceID)
|
||||
db.prepare("DELETE FROM guild_active WHERE guild_id=?").run(guild_id)
|
||||
await db.prepare("DELETE FROM guild_space WHERE guild_id=? AND space_id=?").run(guild_id, spaceID)
|
||||
await db.prepare("DELETE FROM guild_active WHERE guild_id=?").run(guild_id)
|
||||
await discord.snow.user.leaveGuild(guild_id)
|
||||
db.prepare("DELETE FROM invite WHERE room_id=?").run(spaceID)
|
||||
await db.prepare("DELETE FROM invite WHERE room_id=?").run(spaceID)
|
||||
|
||||
setResponseHeader(event, "HX-Redirect", "/")
|
||||
return null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue