Fix matrix api joinRoom() for remote rooms #60
4 changed files with 14 additions and 3 deletions
9
jsconfig.json
Normal file
9
jsconfig.json
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2024",
|
||||
"module": "nodenext",
|
||||
"strict": true,
|
||||
"noImplicitAny": false,
|
||||
"useUnknownInCatchVariables": false
|
||||
}
|
||||
}
|
||||
|
|
@ -207,6 +207,7 @@ async function attachmentToEvent(mentions, attachment) {
|
|||
* - alwaysReturnFormattedBody: false - formatted_body will be skipped if it is the same as body because the message is plaintext. if you want the formatted_body to be returned anyway, for example to merge it with another message, then set this to true.
|
||||
* - scanTextForMentions: true - needs to be set to false when converting forwarded messages etc which may be from a different channel that can't be scanned.
|
||||
* @param {{api: import("../../matrix/api"), snow?: import("snowtransfer").SnowTransfer}} di simple-as-nails dependency injection for the matrix API
|
||||
* @returns {Promise<{$type: string, $sender?: string, [x: string]: any}[]>}
|
||||
*/
|
||||
async function messageToEvent(message, guild, options = {}, di) {
|
||||
const events = []
|
||||
|
|
|
|||
4
src/types.d.ts
vendored
4
src/types.d.ts
vendored
|
|
@ -149,7 +149,7 @@ export namespace Event {
|
|||
prev_content?: any
|
||||
}
|
||||
|
||||
export type Outer_StrippedChildStateEvent = {
|
||||
export type StrippedChildStateEvent = {
|
||||
type: string
|
||||
state_key: string
|
||||
sender: string
|
||||
|
|
@ -353,7 +353,7 @@ export namespace R {
|
|||
export type Hierarchy = {
|
||||
avatar_url?: string
|
||||
canonical_alias?: string
|
||||
children_state: Event.Outer_StrippedChildStateEvent[]
|
||||
children_state: Event.StrippedChildStateEvent[]
|
||||
guest_can_join: boolean
|
||||
join_rule?: string
|
||||
name?: string
|
||||
|
|
|
|||
|
|
@ -76,7 +76,8 @@ as.router.post("/api/link-space", defineEventHandler(async event => {
|
|||
if (existing) throw createError({status: 400, message: "Bad Request", data: `Guild ID ${guildID} or space ID ${spaceID} are already bridged and cannot be reused`})
|
||||
|
||||
const inviteSender = select("invite", "mxid", {mxid: session.data.mxid, room_id: spaceID}).pluck().get()
|
||||
const via = [ inviteSender?.match(/:(.*)/)?.[1] ?? "" ]
|
||||
const inviteSenderServer = inviteSender?.match(/:(.*)/)?.[1]
|
||||
const via = [inviteSenderServer || ""]
|
||||
|
|
||||
|
||||
// Check space exists and bridge is joined
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue
Where are you going to find
viahere?Hmmm, I didn't change that because the bridge needed to be manually invited to the space so that it can be selected.
However indeed, if the bridge is invited to the space, then kicked, the button to the space remains and if clicked, we have the same issue than for joining rooms, didn't notice that.
From the Client-Server API doc there doesn't seem to be "via" or "server_name" information on the
m.room.memberevent, so I'm not sure.I guess it should be safe to take the HS part of the user from
senderin them.room.member: as this user is able to send an invite, the space must be reachable through the inviter's HS(unless the invite is old, all users from this HS left the space, and the room was purged from the HS, but nothing we can do about that)
Last commit uses that, should we add a check to enrich the error message too if for some reasons we cannot detect the via?
Added the error message asking to manually invite in case if /api/link-space joinRoom fails, similarly to /api/link