mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-16 06:02:24 +03:00
Get room versions from database (#918)
* Retrieve room version where known in roomserver * Get room versions in alias code * Increase gocyclothreshold to 13, since we hit that number a lot * Remove gocyclo nolint from StoreEvent * Update interface to get room version from room ID instead of NID * Remove new API * Fixed this query for SQLite but not for Postgres
This commit is contained in:
parent
1467cc10d8
commit
c2bd0b97b3
11 changed files with 68 additions and 45 deletions
|
@ -46,6 +46,10 @@ 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
|
||||
// Look up the room version for a given room.
|
||||
GetRoomVersionForRoom(
|
||||
ctx context.Context, roomID string,
|
||||
) (gomatrixserverlib.RoomVersion, error)
|
||||
}
|
||||
|
||||
// RoomserverAliasAPI is an implementation of alias.RoomserverAliasAPI
|
||||
|
@ -240,6 +244,11 @@ func (r *RoomserverAliasAPI) sendUpdatedAliasesEvent(
|
|||
}
|
||||
builder.AuthEvents = refs
|
||||
|
||||
roomVersion, err := r.DB.GetRoomVersionForRoom(ctx, roomID)
|
||||
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 +259,6 @@ func (r *RoomserverAliasAPI) sendUpdatedAliasesEvent(
|
|||
return err
|
||||
}
|
||||
|
||||
// TODO: Room version here
|
||||
roomVersion := gomatrixserverlib.RoomVersionV1
|
||||
|
||||
// Create the request
|
||||
ire := roomserverAPI.InputRoomEvent{
|
||||
Kind: roomserverAPI.KindNew,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue