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()
|
const webhook = select("webhook", ["webhook_id", "webhook_token"], {channel_id: channel.id}).get()
|
||||||
if (webhook) {
|
if (webhook) {
|
||||||
await discord.snow.webhook.deleteWebhook(webhook.webhook_id, webhook.webhook_token)
|
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
|
// delete room from database
|
||||||
db.prepare("DELETE FROM member_cache WHERE room_id = ?").run(roomID)
|
await 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 channel_room WHERE room_id = ? AND channel_id = ?").run(roomID, channel.id) // cascades to most other tables, like messages
|
||||||
|
|
||||||
if (!botInRoom) return
|
if (!botInRoom) return
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -274,15 +274,6 @@ as.router.post("/api/unlink-space", defineEventHandler(async event => {
|
||||||
|
|
||||||
|
cadence marked this conversation as resolved
Outdated
|
|||||||
for (const channel of linkedChannels) {
|
for (const channel of linkedChannels) {
|
||||||
await doRoomUnlink(event, channel.channel_id, guild_id)
|
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()
|
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.setUserPower(spaceID, me, 0)
|
||||||
await api.leaveRoom(spaceID)
|
await api.leaveRoom(spaceID)
|
||||||
|
|
||||||
db.prepare("DELETE FROM guild_space WHERE guild_id=? AND space_id=?").run(guild_id, spaceID)
|
await 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_active WHERE guild_id=?").run(guild_id)
|
||||||
await discord.snow.user.leaveGuild(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", "/")
|
setResponseHeader(event, "HX-Redirect", "/")
|
||||||
return null
|
return null
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue
Hi, there is this issue here, I'm not sure what would be the best thing to do with this situation, please let me know if you have any ideas of what should be best
Nice find, thanks for pointing it out. For further reading, the purpose and values of guild_active are explained here: https://gitdab.com/cadence/out-of-your-element/src/branch/main/docs/self-service-room-creation-rules.md
The message "Please add the bot to your server using the buttons on the home page" is deliberately designed to appear in this situation. However, the user experience here could be better.
There's a couple of possible paths forward here:
Because per the explainer doc, it's bad to leave around the a guild_active entry if you don't want the guild to be bridged. If Easy Mode was previously selected, it would cause channels to bridge themselves again just from anybody sending a message in the server. That would be pretty weird if somebody just clicked unbridge and it starts bridging again seemingly by itself! So we can't just do nothing here.
I'll let you pick which path forward you'd like to go with. I don't have any preference between the first two.
I note that you've coded it to always leave the Matrix space after this operation. I don't think it would be out of character for it to leave the Discord server as well.
Ok, I just pushed doing a full clean of
guild_space,guild_active,invite, and leaving the discord server.The clean of
inviteis not strictly necessary, but I you don't clean it, it might lead to buttons in the "select a space" from the self service mode later where the unbridged space is here but if you click it, you get an error because it cannot join it