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)
|
||||
// check it's free TODO: This races but is better than nothing
|
||||
hasAliasReq := roomserverAPI.GetRoomIDForAliasRequest{
|
||||
Alias: roomAlias,
|
||||
Alias: roomAlias,
|
||||
ShouldHitAppservice: false,
|
||||
}
|
||||
|
||||
var aliasResp roomserverAPI.GetRoomIDForAliasResponse
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ func DirectoryRoom(
|
|||
var res roomDirectoryResponse
|
||||
|
||||
// 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
|
||||
if err = rsAPI.GetRoomIDForAlias(req.Context(), &queryReq, &queryRes); err != nil {
|
||||
util.GetLogger(req.Context()).WithError(err).Error("rsAPI.GetRoomIDForAlias failed")
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ func RoomAliasToID(
|
|||
var resp gomatrixserverlib.RespDirectory
|
||||
|
||||
if domain == cfg.Matrix.ServerName {
|
||||
queryReq := roomserverAPI.GetRoomIDForAliasRequest{Alias: roomAlias}
|
||||
queryReq := roomserverAPI.GetRoomIDForAliasRequest{Alias: roomAlias, ShouldHitAppservice: true}
|
||||
var queryRes roomserverAPI.GetRoomIDForAliasResponse
|
||||
if err = rsAPI.GetRoomIDForAlias(httpReq.Context(), &queryReq, &queryRes); err != nil {
|
||||
util.GetLogger(httpReq.Context()).WithError(err).Error("aliasAPI.GetRoomIDForAlias failed")
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ type SetRoomAliasResponse struct {
|
|||
// GetRoomIDForAliasRequest is a request to GetRoomIDForAlias
|
||||
type GetRoomIDForAliasRequest struct {
|
||||
// Alias we want to lookup
|
||||
Alias string `json:"alias"`
|
||||
Alias string `json:"alias"`
|
||||
ShouldHitAppservice bool `json:"shouldHitAppservice"`
|
||||
}
|
||||
|
||||
// GetRoomIDForAliasResponse is a response to GetRoomIDForAlias
|
||||
|
|
|
|||
|
|
@ -88,11 +88,13 @@ func (r *RoomserverInternalAPI) GetRoomIDForAlias(
|
|||
) error {
|
||||
// Look up the room ID in the database
|
||||
roomID, err := r.DB.GetRoomIDForAlias(ctx, request.Alias)
|
||||
if err != nil {
|
||||
return err
|
||||
if err == nil && roomID != "" {
|
||||
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 == "" {
|
||||
// No room found locally, try our application services by making a call to
|
||||
// the appservice component
|
||||
|
|
@ -107,12 +109,13 @@ func (r *RoomserverInternalAPI) GetRoomIDForAlias(
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response.RoomID = roomID
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response.RoomID = roomID
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
// GetAliasesForRoomID implements alias.RoomserverInternalAPI
|
||||
|
|
|
|||
Loading…
Reference in a new issue