mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 13:22:46 +00:00
de-MSC-ifying space summaries (MSC2946) (#3134)
- This PR moves and refactors the [code](https://github.com/matrix-org/dendrite/blob/main/setup/mscs/msc2946/msc2946.go) for [MSC2946](https://github.com/matrix-org/matrix-spec-proposals/pull/2946) ('Space Summaries') to integrate it into the rest of the codebase. - Means space summaries are no longer hidden behind an MSC flag - Solves #3096 Signed-off-by: Sam Wedgwood <sam@wedgwood.dev>
This commit is contained in:
parent
297479ea49
commit
9582827493
39 changed files with 1034 additions and 810 deletions
|
@ -22,7 +22,9 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
userapi "github.com/matrix-org/dendrite/userapi/api"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
"github.com/matrix-org/gomatrixserverlib/spec"
|
||||
"github.com/matrix-org/util"
|
||||
"golang.org/x/crypto/blake2b"
|
||||
)
|
||||
|
@ -336,3 +338,36 @@ func (r *RoomInfo) CopyFrom(r2 *RoomInfo) {
|
|||
}
|
||||
|
||||
var ErrorInvalidRoomInfo = fmt.Errorf("room info is invalid")
|
||||
|
||||
// Struct to represent a device or a server name.
|
||||
//
|
||||
// May be used to designate a caller for functions that can be called
|
||||
// by a client (device) or by a server (server name).
|
||||
//
|
||||
// Exactly 1 of Device() and ServerName() will return a non-nil result.
|
||||
type DeviceOrServerName struct {
|
||||
device *userapi.Device
|
||||
serverName *spec.ServerName
|
||||
}
|
||||
|
||||
func NewDeviceNotServerName(device userapi.Device) DeviceOrServerName {
|
||||
return DeviceOrServerName{
|
||||
device: &device,
|
||||
serverName: nil,
|
||||
}
|
||||
}
|
||||
|
||||
func NewServerNameNotDevice(serverName spec.ServerName) DeviceOrServerName {
|
||||
return DeviceOrServerName{
|
||||
device: nil,
|
||||
serverName: &serverName,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DeviceOrServerName) Device() *userapi.Device {
|
||||
return s.device
|
||||
}
|
||||
|
||||
func (s *DeviceOrServerName) ServerName() *spec.ServerName {
|
||||
return s.serverName
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue