1
0
Fork 0

continue if user is already invited

This commit is contained in:
Cadence Ember 2023-09-03 10:47:01 +12:00
parent 6803b156bc
commit dd4e3aa8e0
2 changed files with 13 additions and 6 deletions

View file

@ -72,8 +72,16 @@ async function ensureSimJoined(user, roomID) {
// Ensure joined
const existing = db.prepare("SELECT * FROM sim_member WHERE room_id = ? and mxid = ?").get(roomID, mxid)
if (!existing) {
await api.inviteToRoom(roomID, mxid)
await api.joinRoom(roomID, mxid)
try {
await api.inviteToRoom(roomID, mxid)
await api.joinRoom(roomID, mxid)
} catch (e) {
if (e.message.includes("is already in the room.")) {
// Sweet!
} else {
throw e
}
}
db.prepare("INSERT INTO sim_member (room_id, mxid) VALUES (?, ?)").run(roomID, mxid)
}
return mxid