From 3a66d3c6cf7cee534bdb3fb4f0c7c8bd27ac89eb Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Tue, 5 Jan 2021 10:56:09 +0000 Subject: [PATCH] Hit appservice when trying to join a non-existent alias --- roomserver/internal/api.go | 1 + roomserver/internal/perform/perform_join.go | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/roomserver/internal/api.go b/roomserver/internal/api.go index 91caa0bdc..c04a4ccd0 100644 --- a/roomserver/internal/api.go +++ b/roomserver/internal/api.go @@ -88,6 +88,7 @@ func (r *RoomserverInternalAPI) SetFederationSenderAPI(fsAPI fsAPI.FederationSen Cfg: r.Cfg, DB: r.DB, FSAPI: r.fsAPI, + RSAPI: r, Inputer: r.Inputer, } r.Peeker = &perform.Peeker{ diff --git a/roomserver/internal/perform/perform_join.go b/roomserver/internal/perform/perform_join.go index 8eb6b648e..7f0020a5c 100644 --- a/roomserver/internal/perform/perform_join.go +++ b/roomserver/internal/perform/perform_join.go @@ -24,18 +24,21 @@ import ( fsAPI "github.com/matrix-org/dendrite/federationsender/api" "github.com/matrix-org/dendrite/internal/eventutil" "github.com/matrix-org/dendrite/roomserver/api" + rsAPI "github.com/matrix-org/dendrite/roomserver/api" "github.com/matrix-org/dendrite/roomserver/internal/helpers" "github.com/matrix-org/dendrite/roomserver/internal/input" "github.com/matrix-org/dendrite/roomserver/storage" "github.com/matrix-org/dendrite/setup/config" "github.com/matrix-org/gomatrixserverlib" "github.com/sirupsen/logrus" + log "github.com/sirupsen/logrus" ) type Joiner struct { ServerName gomatrixserverlib.ServerName Cfg *config.RoomServer FSAPI fsAPI.FederationSenderInternalAPI + RSAPI rsAPI.RoomserverInternalAPI DB storage.Database Inputer *input.Inputer @@ -121,11 +124,17 @@ func (r *Joiner) performJoinRoomByAlias( roomID = dirRes.RoomID req.ServerNames = append(req.ServerNames, dirRes.ServerNames...) } else { + var getRoomReq = rsAPI.GetRoomIDForAliasRequest{ + Alias: req.RoomIDOrAlias, + ShouldHitAppservice: true, + } + var getRoomRes = rsAPI.GetRoomIDForAliasResponse{} // Otherwise, look up if we know this room alias locally. - roomID, err = r.DB.GetRoomIDForAlias(ctx, req.RoomIDOrAlias) + err = r.RSAPI.GetRoomIDForAlias(ctx, &getRoomReq, &getRoomRes) if err != nil { return "", "", fmt.Errorf("Lookup room alias %q failed: %w", req.RoomIDOrAlias, err) } + roomID = getRoomRes.RoomID } // If the room ID is empty then we failed to look up the alias.