Fix matrix api joinRoom() for remote rooms #60
1 changed files with 3 additions and 0 deletions
|
|
@ -96,6 +96,9 @@ as.router.post("/api/link-space", defineEventHandler(async event => {
|
||||||
try {
|
try {
|
||||||
await api.joinRoom(parsedBody.space_id, null, via)
|
await api.joinRoom(parsedBody.space_id, null, via)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
if (via.join("") == "") {
|
||||||
|
|
|||||||
|
throw createError({status: 403, message: "Unable To Join", data: `Unable to join the requested Matrix space. Please invite the bridge to the space and try again. (Server said: ${e.errcode} - ${e.message})`})
|
||||||
|
cadence
commented
Status code 400 please. Note that this error message doesn't make much sense. The user has to have already invited the bridge to the space to reach this point. I honestly don't know what advice would be good to give if this occurs, because accepting an invite should always work, even for remote invites. /shrug Status code 400 please.
Note that this error message doesn't make much sense. The user has to have already invited the bridge to the space to reach this point.
I honestly don't know what advice would be good to give if this occurs, because accepting an invite should always work, even for remote invites. /shrug
Elliu
commented
Yeah, I don't know.
Don't know if all of this even makes sense Yeah, I don't know.
The idea at the back of my mind was a weird state that could happen if:
1. Space is not on the same HS than bridge
1. Bridge is invited / join the space
2. User kicks / remove the bridge from the space
3. User leave the space
4. No remaining user from this HS on the space, space is purged from the user's HS
5. `/api/link-space` gets called somehow(?)
6. bridge tries to join using the "via" of origin invite, but space got purged from the via-ed HS in between, so fails, requiring a reinvite from a user that is currently in the space
Don't know if all of this even makes sense
|
|||||||
|
}
|
||||||
throw createError({status: 403, message: e.errcode, data: `${e.errcode} - ${e.message}`})
|
throw createError({status: 403, message: e.errcode, data: `${e.errcode} - ${e.message}`})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue
This condition can't happen, because it's always possible to extract a
viafrom the user who sent the invite. Remove the if statement and just always use the more detailed error message.