diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2020-12-18 13:33:28 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-18 13:33:28 +0000 |
commit | fac71edc62508e517b188e00fb64651910761ff0 (patch) | |
tree | 8da8cc87de327c3fffa0325f16491b47ab34d2fb /roomserver/internal | |
parent | 65ff5c9a2c0b81cb9c6df6fb6e27418577eb1160 (diff) |
Fix #1655 by re-adding the appservice alias query (#1660)
Diffstat (limited to 'roomserver/internal')
-rw-r--r-- | roomserver/internal/alias.go | 16 | ||||
-rw-r--r-- | roomserver/internal/api.go | 6 |
2 files changed, 13 insertions, 9 deletions
diff --git a/roomserver/internal/alias.go b/roomserver/internal/alias.go index 97b2ddf5..843b0bcc 100644 --- a/roomserver/internal/alias.go +++ b/roomserver/internal/alias.go @@ -23,6 +23,8 @@ import ( "github.com/matrix-org/dendrite/roomserver/api" "github.com/matrix-org/gomatrixserverlib" + + asAPI "github.com/matrix-org/dendrite/appservice/api" ) // RoomserverInternalAPIDatabase has the storage APIs needed to implement the alias API. @@ -90,17 +92,13 @@ func (r *RoomserverInternalAPI) GetRoomIDForAlias( return err } - /* - TODO: Why is this here? It creates an unnecessary dependency - from the roomserver to the appservice component, which should be - altogether optional. - + if r.asAPI != nil { // appservice component is wired in if roomID == "" { // No room found locally, try our application services by making a call to // the appservice component - aliasReq := appserviceAPI.RoomAliasExistsRequest{Alias: request.Alias} - var aliasResp appserviceAPI.RoomAliasExistsResponse - if err = r.AppserviceAPI.RoomAliasExists(ctx, &aliasReq, &aliasResp); err != nil { + aliasReq := asAPI.RoomAliasExistsRequest{Alias: request.Alias} + var aliasResp asAPI.RoomAliasExistsResponse + if err = r.asAPI.RoomAliasExists(ctx, &aliasReq, &aliasResp); err != nil { return err } @@ -111,7 +109,7 @@ func (r *RoomserverInternalAPI) GetRoomIDForAlias( } } } - */ + } response.RoomID = roomID return nil diff --git a/roomserver/internal/api.go b/roomserver/internal/api.go index 1ad971ec..91caa0bd 100644 --- a/roomserver/internal/api.go +++ b/roomserver/internal/api.go @@ -4,6 +4,7 @@ import ( "context" "github.com/Shopify/sarama" + asAPI "github.com/matrix-org/dendrite/appservice/api" fsAPI "github.com/matrix-org/dendrite/federationsender/api" "github.com/matrix-org/dendrite/internal/caching" "github.com/matrix-org/dendrite/roomserver/acls" @@ -35,6 +36,7 @@ type RoomserverInternalAPI struct { ServerName gomatrixserverlib.ServerName KeyRing gomatrixserverlib.JSONVerifier fsAPI fsAPI.FederationSenderInternalAPI + asAPI asAPI.AppServiceQueryAPI OutputRoomEventTopic string // Kafka topic for new output room events PerspectiveServerNames []gomatrixserverlib.ServerName } @@ -126,6 +128,10 @@ func (r *RoomserverInternalAPI) SetFederationSenderAPI(fsAPI fsAPI.FederationSen } } +func (r *RoomserverInternalAPI) SetAppserviceAPI(asAPI asAPI.AppServiceQueryAPI) { + r.asAPI = asAPI +} + func (r *RoomserverInternalAPI) PerformInvite( ctx context.Context, req *api.PerformInviteRequest, |