mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-26 00:03:09 -06:00
Add field ShouldHitAppservice to GetRoomIDForAlias
This commit is contained in:
parent
a5ba01eb76
commit
85c564ef9a
|
|
@ -216,7 +216,8 @@ func createRoom(
|
||||||
roomAlias = fmt.Sprintf("#%s:%s", r.RoomAliasName, cfg.Matrix.ServerName)
|
roomAlias = fmt.Sprintf("#%s:%s", r.RoomAliasName, cfg.Matrix.ServerName)
|
||||||
// check it's free TODO: This races but is better than nothing
|
// check it's free TODO: This races but is better than nothing
|
||||||
hasAliasReq := roomserverAPI.GetRoomIDForAliasRequest{
|
hasAliasReq := roomserverAPI.GetRoomIDForAliasRequest{
|
||||||
Alias: roomAlias,
|
Alias: roomAlias,
|
||||||
|
ShouldHitAppservice: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
var aliasResp roomserverAPI.GetRoomIDForAliasResponse
|
var aliasResp roomserverAPI.GetRoomIDForAliasResponse
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ func DirectoryRoom(
|
||||||
var res roomDirectoryResponse
|
var res roomDirectoryResponse
|
||||||
|
|
||||||
// Query the roomserver API to check if the alias exists locally.
|
// Query the roomserver API to check if the alias exists locally.
|
||||||
queryReq := roomserverAPI.GetRoomIDForAliasRequest{Alias: roomAlias}
|
queryReq := roomserverAPI.GetRoomIDForAliasRequest{Alias: roomAlias, ShouldHitAppservice: true}
|
||||||
var queryRes roomserverAPI.GetRoomIDForAliasResponse
|
var queryRes roomserverAPI.GetRoomIDForAliasResponse
|
||||||
if err = rsAPI.GetRoomIDForAlias(req.Context(), &queryReq, &queryRes); err != nil {
|
if err = rsAPI.GetRoomIDForAlias(req.Context(), &queryReq, &queryRes); err != nil {
|
||||||
util.GetLogger(req.Context()).WithError(err).Error("rsAPI.GetRoomIDForAlias failed")
|
util.GetLogger(req.Context()).WithError(err).Error("rsAPI.GetRoomIDForAlias failed")
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ func RoomAliasToID(
|
||||||
var resp gomatrixserverlib.RespDirectory
|
var resp gomatrixserverlib.RespDirectory
|
||||||
|
|
||||||
if domain == cfg.Matrix.ServerName {
|
if domain == cfg.Matrix.ServerName {
|
||||||
queryReq := roomserverAPI.GetRoomIDForAliasRequest{Alias: roomAlias}
|
queryReq := roomserverAPI.GetRoomIDForAliasRequest{Alias: roomAlias, ShouldHitAppservice: true}
|
||||||
var queryRes roomserverAPI.GetRoomIDForAliasResponse
|
var queryRes roomserverAPI.GetRoomIDForAliasResponse
|
||||||
if err = rsAPI.GetRoomIDForAlias(httpReq.Context(), &queryReq, &queryRes); err != nil {
|
if err = rsAPI.GetRoomIDForAlias(httpReq.Context(), &queryReq, &queryRes); err != nil {
|
||||||
util.GetLogger(httpReq.Context()).WithError(err).Error("aliasAPI.GetRoomIDForAlias failed")
|
util.GetLogger(httpReq.Context()).WithError(err).Error("aliasAPI.GetRoomIDForAlias failed")
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,8 @@ type SetRoomAliasResponse struct {
|
||||||
// GetRoomIDForAliasRequest is a request to GetRoomIDForAlias
|
// GetRoomIDForAliasRequest is a request to GetRoomIDForAlias
|
||||||
type GetRoomIDForAliasRequest struct {
|
type GetRoomIDForAliasRequest struct {
|
||||||
// Alias we want to lookup
|
// Alias we want to lookup
|
||||||
Alias string `json:"alias"`
|
Alias string `json:"alias"`
|
||||||
|
ShouldHitAppservice bool `json:"shouldHitAppservice"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRoomIDForAliasResponse is a response to GetRoomIDForAlias
|
// GetRoomIDForAliasResponse is a response to GetRoomIDForAlias
|
||||||
|
|
|
||||||
|
|
@ -88,11 +88,13 @@ func (r *RoomserverInternalAPI) GetRoomIDForAlias(
|
||||||
) error {
|
) error {
|
||||||
// Look up the room ID in the database
|
// Look up the room ID in the database
|
||||||
roomID, err := r.DB.GetRoomIDForAlias(ctx, request.Alias)
|
roomID, err := r.DB.GetRoomIDForAlias(ctx, request.Alias)
|
||||||
if err != nil {
|
if err == nil && roomID != "" {
|
||||||
return err
|
response.RoomID = roomID
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.asAPI != nil { // appservice component is wired in
|
// Check appservice on err
|
||||||
|
if r.asAPI != nil && request.ShouldHitAppservice { // appservice component is wired in
|
||||||
if roomID == "" {
|
if roomID == "" {
|
||||||
// No room found locally, try our application services by making a call to
|
// No room found locally, try our application services by making a call to
|
||||||
// the appservice component
|
// the appservice component
|
||||||
|
|
@ -107,12 +109,13 @@ func (r *RoomserverInternalAPI) GetRoomIDForAlias(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
response.RoomID = roomID
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
response.RoomID = roomID
|
return err
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAliasesForRoomID implements alias.RoomserverInternalAPI
|
// GetAliasesForRoomID implements alias.RoomserverInternalAPI
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue