mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-01 13:52:46 +00:00
refactor: update GMSL (#3058)
Sister PR to https://github.com/matrix-org/gomatrixserverlib/pull/364 Read this commit by commit to avoid going insane.
This commit is contained in:
parent
9fa39263c0
commit
72285b2659
306 changed files with 2117 additions and 1934 deletions
|
@ -20,6 +20,7 @@ import (
|
|||
"sort"
|
||||
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
"github.com/matrix-org/gomatrixserverlib/spec"
|
||||
|
||||
"github.com/matrix-org/dendrite/roomserver/state"
|
||||
"github.com/matrix-org/dendrite/roomserver/storage"
|
||||
|
@ -59,7 +60,7 @@ func CheckForSoftFail(
|
|||
// state because we haven't received a m.room.create event yet.
|
||||
// If we're now processing the first create event then never
|
||||
// soft-fail it.
|
||||
if len(authStateEntries) == 0 && event.Type() == gomatrixserverlib.MRoomCreate {
|
||||
if len(authStateEntries) == 0 && event.Type() == spec.MRoomCreate {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
"github.com/matrix-org/gomatrixserverlib/spec"
|
||||
"github.com/matrix-org/util"
|
||||
|
||||
"github.com/matrix-org/dendrite/roomserver/api"
|
||||
|
@ -54,7 +55,7 @@ func UpdateToInviteMembership(
|
|||
Type: api.OutputTypeRetireInviteEvent,
|
||||
RetireInviteEvent: &api.OutputRetireInviteEvent{
|
||||
EventID: eventID,
|
||||
Membership: gomatrixserverlib.Join,
|
||||
Membership: spec.Join,
|
||||
RetiredByEventID: add.EventID(),
|
||||
TargetUserID: *add.StateKey(),
|
||||
},
|
||||
|
@ -67,7 +68,7 @@ func UpdateToInviteMembership(
|
|||
// memberships. If the servername is not supplied then the local server will be
|
||||
// checked instead using a faster code path.
|
||||
// TODO: This should probably be replaced by an API call.
|
||||
func IsServerCurrentlyInRoom(ctx context.Context, db storage.Database, serverName gomatrixserverlib.ServerName, roomID string) (bool, error) {
|
||||
func IsServerCurrentlyInRoom(ctx context.Context, db storage.Database, serverName spec.ServerName, roomID string) (bool, error) {
|
||||
info, err := db.RoomInfo(ctx, roomID)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
@ -93,7 +94,7 @@ func IsServerCurrentlyInRoom(ctx context.Context, db storage.Database, serverNam
|
|||
for i := range events {
|
||||
gmslEvents[i] = events[i].Event
|
||||
}
|
||||
return auth.IsAnyUserOnServerWithMembership(serverName, gmslEvents, gomatrixserverlib.Join), nil
|
||||
return auth.IsAnyUserOnServerWithMembership(serverName, gmslEvents, spec.Join), nil
|
||||
}
|
||||
|
||||
func IsInvitePending(
|
||||
|
@ -194,7 +195,7 @@ func GetMembershipsAtState(
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if membership == gomatrixserverlib.Join {
|
||||
if membership == spec.Join {
|
||||
events = append(events, event)
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +253,7 @@ func LoadStateEvents(
|
|||
}
|
||||
|
||||
func CheckServerAllowedToSeeEvent(
|
||||
ctx context.Context, db storage.Database, info *types.RoomInfo, eventID string, serverName gomatrixserverlib.ServerName, isServerInRoom bool,
|
||||
ctx context.Context, db storage.Database, info *types.RoomInfo, eventID string, serverName spec.ServerName, isServerInRoom bool,
|
||||
) (bool, error) {
|
||||
stateAtEvent, err := db.GetHistoryVisibilityState(ctx, info, eventID, string(serverName))
|
||||
switch err {
|
||||
|
@ -280,7 +281,7 @@ func CheckServerAllowedToSeeEvent(
|
|||
}
|
||||
|
||||
func slowGetHistoryVisibilityState(
|
||||
ctx context.Context, db storage.Database, info *types.RoomInfo, eventID string, serverName gomatrixserverlib.ServerName,
|
||||
ctx context.Context, db storage.Database, info *types.RoomInfo, eventID string, serverName spec.ServerName,
|
||||
) ([]*gomatrixserverlib.Event, error) {
|
||||
roomState := state.NewStateResolution(db, info)
|
||||
stateEntries, err := roomState.LoadStateAtEvent(ctx, eventID)
|
||||
|
@ -332,7 +333,7 @@ func slowGetHistoryVisibilityState(
|
|||
// TODO: Remove this when we have tests to assert correctness of this function
|
||||
func ScanEventTree(
|
||||
ctx context.Context, db storage.Database, info *types.RoomInfo, front []string, visited map[string]bool, limit int,
|
||||
serverName gomatrixserverlib.ServerName,
|
||||
serverName spec.ServerName,
|
||||
) ([]types.EventNID, map[string]struct{}, error) {
|
||||
var resultNIDs []types.EventNID
|
||||
var err error
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue