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"
|
||||||
"github.com/matrix-org/dendrite/common/config"
|
"github.com/matrix-org/dendrite/common/config"
|
||||||
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
|
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
|
||||||
|
"github.com/matrix-org/dendrite/roomserver/types"
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
"github.com/matrix-org/util"
|
"github.com/matrix-org/util"
|
||||||
)
|
)
|
||||||
|
|
@ -46,6 +47,12 @@ type RoomserverAliasAPIDatabase interface {
|
||||||
// Remove a given room alias.
|
// Remove a given room alias.
|
||||||
// Returns an error if there was a problem talking to the database.
|
// Returns an error if there was a problem talking to the database.
|
||||||
RemoveRoomAlias(ctx context.Context, alias string) error
|
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
|
// RoomserverAliasAPI is an implementation of alias.RoomserverAliasAPI
|
||||||
|
|
@ -240,6 +247,16 @@ func (r *RoomserverAliasAPI) sendUpdatedAliasesEvent(
|
||||||
}
|
}
|
||||||
builder.AuthEvents = refs
|
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
|
// Build the event
|
||||||
eventID := fmt.Sprintf("$%s:%s", util.RandomString(16), r.Cfg.Matrix.ServerName)
|
eventID := fmt.Sprintf("$%s:%s", util.RandomString(16), r.Cfg.Matrix.ServerName)
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
@ -250,9 +267,6 @@ func (r *RoomserverAliasAPI) sendUpdatedAliasesEvent(
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Room version here
|
|
||||||
roomVersion := gomatrixserverlib.RoomVersionV1
|
|
||||||
|
|
||||||
// Create the request
|
// Create the request
|
||||||
ire := roomserverAPI.InputRoomEvent{
|
ire := roomserverAPI.InputRoomEvent{
|
||||||
Kind: roomserverAPI.KindNew,
|
Kind: roomserverAPI.KindNew,
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ import (
|
||||||
|
|
||||||
appserviceAPI "github.com/matrix-org/dendrite/appservice/api"
|
appserviceAPI "github.com/matrix-org/dendrite/appservice/api"
|
||||||
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
|
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
|
||||||
|
"github.com/matrix-org/dendrite/roomserver/types"
|
||||||
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MockRoomserverAliasAPIDatabase struct {
|
type MockRoomserverAliasAPIDatabase struct {
|
||||||
|
|
@ -49,6 +51,18 @@ func (db *MockRoomserverAliasAPIDatabase) GetCreatorIDForAlias(
|
||||||
return "", nil
|
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
|
// This method needs to change depending on test case
|
||||||
func (db *MockRoomserverAliasAPIDatabase) GetRoomIDForAlias(
|
func (db *MockRoomserverAliasAPIDatabase) GetRoomIDForAlias(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue