mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-16 11:23:11 -06:00
Get room versions in alias code
This commit is contained in:
parent
bc8735ebc6
commit
1ffff85e02
|
|
@ -25,6 +25,7 @@ import (
|
|||
"github.com/matrix-org/dendrite/common"
|
||||
"github.com/matrix-org/dendrite/common/config"
|
||||
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
|
||||
"github.com/matrix-org/dendrite/roomserver/types"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
"github.com/matrix-org/util"
|
||||
)
|
||||
|
|
@ -46,6 +47,12 @@ type RoomserverAliasAPIDatabase interface {
|
|||
// Remove a given room alias.
|
||||
// Returns an error if there was a problem talking to the database.
|
||||
RemoveRoomAlias(ctx context.Context, alias string) error
|
||||
// Return the room NID for a room ID.
|
||||
RoomNID(ctx context.Context, roomID string) (types.RoomNID, error)
|
||||
// Look up the room version for a given room.
|
||||
GetRoomVersionForRoom(
|
||||
ctx context.Context, roomNID types.RoomNID,
|
||||
) (gomatrixserverlib.RoomVersion, error)
|
||||
}
|
||||
|
||||
// RoomserverAliasAPI is an implementation of alias.RoomserverAliasAPI
|
||||
|
|
@ -240,6 +247,16 @@ func (r *RoomserverAliasAPI) sendUpdatedAliasesEvent(
|
|||
}
|
||||
builder.AuthEvents = refs
|
||||
|
||||
roomNID, err := r.DB.RoomNID(ctx, roomID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
roomVersion, err := r.DB.GetRoomVersionForRoom(ctx, roomNID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Build the event
|
||||
eventID := fmt.Sprintf("$%s:%s", util.RandomString(16), r.Cfg.Matrix.ServerName)
|
||||
now := time.Now()
|
||||
|
|
@ -250,9 +267,6 @@ func (r *RoomserverAliasAPI) sendUpdatedAliasesEvent(
|
|||
return err
|
||||
}
|
||||
|
||||
// TODO: Room version here
|
||||
roomVersion := gomatrixserverlib.RoomVersionV1
|
||||
|
||||
// Create the request
|
||||
ire := roomserverAPI.InputRoomEvent{
|
||||
Kind: roomserverAPI.KindNew,
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ import (
|
|||
|
||||
appserviceAPI "github.com/matrix-org/dendrite/appservice/api"
|
||||
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
|
||||
"github.com/matrix-org/dendrite/roomserver/types"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
)
|
||||
|
||||
type MockRoomserverAliasAPIDatabase struct {
|
||||
|
|
@ -49,6 +51,18 @@ func (db *MockRoomserverAliasAPIDatabase) GetCreatorIDForAlias(
|
|||
return "", nil
|
||||
}
|
||||
|
||||
func (db *MockRoomserverAliasAPIDatabase) RoomNID(
|
||||
ctx context.Context, roomID string,
|
||||
) (types.RoomNID, error) {
|
||||
return 1, nil
|
||||
}
|
||||
|
||||
func (db *MockRoomserverAliasAPIDatabase) GetRoomVersionForRoom(
|
||||
ctx context.Context, roomNID types.RoomNID,
|
||||
) (gomatrixserverlib.RoomVersion, error) {
|
||||
return gomatrixserverlib.RoomVersionV1, nil
|
||||
}
|
||||
|
||||
// This method needs to change depending on test case
|
||||
func (db *MockRoomserverAliasAPIDatabase) GetRoomIDForAlias(
|
||||
ctx context.Context,
|
||||
|
|
|
|||
Loading…
Reference in a new issue