mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-29 12:42:46 +00:00
Move MakeJoin logic to GMSL (#3081)
This commit is contained in:
parent
0489d16f95
commit
67d6876857
80 changed files with 1158 additions and 494 deletions
|
@ -52,7 +52,7 @@ func (r *Admin) PerformAdminEvacuateRoom(
|
|||
return nil, err
|
||||
}
|
||||
if roomInfo == nil || roomInfo.IsStub() {
|
||||
return nil, eventutil.ErrRoomNoExists
|
||||
return nil, eventutil.ErrRoomNoExists{}
|
||||
}
|
||||
|
||||
memberNIDs, err := r.DB.GetMembershipEventNIDsForRoom(ctx, roomInfo.RoomNID, true, true)
|
||||
|
@ -240,7 +240,7 @@ func (r *Admin) PerformAdminDownloadState(
|
|||
}
|
||||
|
||||
if roomInfo == nil || roomInfo.IsStub() {
|
||||
return eventutil.ErrRoomNoExists
|
||||
return eventutil.ErrRoomNoExists{}
|
||||
}
|
||||
|
||||
fwdExtremities, _, depth, err := r.DB.LatestEventIDs(ctx, roomInfo.RoomNID)
|
||||
|
|
|
@ -145,7 +145,7 @@ func (r *Joiner) performJoinRoomByAlias(
|
|||
return r.performJoinRoomByID(ctx, req)
|
||||
}
|
||||
|
||||
// TODO: Break this function up a bit
|
||||
// TODO: Break this function up a bit & move to GMSL
|
||||
// nolint:gocyclo
|
||||
func (r *Joiner) performJoinRoomByID(
|
||||
ctx context.Context,
|
||||
|
@ -286,7 +286,7 @@ func (r *Joiner) performJoinRoomByID(
|
|||
}
|
||||
event, err := eventutil.QueryAndBuildEvent(ctx, &proto, r.Cfg.Matrix, identity, time.Now(), r.RSAPI, &buildRes)
|
||||
|
||||
switch err {
|
||||
switch err.(type) {
|
||||
case nil:
|
||||
// The room join is local. Send the new join event into the
|
||||
// roomserver. First of all check that the user isn't already
|
||||
|
@ -328,7 +328,7 @@ func (r *Joiner) performJoinRoomByID(
|
|||
// Otherwise we'll try a federated join as normal, since it's quite
|
||||
// possible that the room still exists on other servers.
|
||||
if len(req.ServerNames) == 0 {
|
||||
return "", "", eventutil.ErrRoomNoExists
|
||||
return "", "", eventutil.ErrRoomNoExists{}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -274,7 +274,7 @@ func publishNewRoomAndUnpublishOldRoom(
|
|||
|
||||
func (r *Upgrader) validateRoomExists(ctx context.Context, roomID string) error {
|
||||
if _, err := r.URSAPI.QueryRoomVersionForRoom(ctx, roomID); err != nil {
|
||||
return eventutil.ErrRoomNoExists
|
||||
return eventutil.ErrRoomNoExists{}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -556,15 +556,18 @@ func (r *Upgrader) makeHeaderedEvent(ctx context.Context, evTime time.Time, user
|
|||
}
|
||||
var queryRes api.QueryLatestEventsAndStateResponse
|
||||
headeredEvent, err := eventutil.QueryAndBuildEvent(ctx, &proto, r.Cfg.Matrix, identity, evTime, r.URSAPI, &queryRes)
|
||||
if err == eventutil.ErrRoomNoExists {
|
||||
return nil, err
|
||||
} else if e, ok := err.(gomatrixserverlib.BadJSONError); ok {
|
||||
switch e := err.(type) {
|
||||
case nil:
|
||||
case eventutil.ErrRoomNoExists:
|
||||
return nil, e
|
||||
} else if e, ok := err.(gomatrixserverlib.EventValidationError); ok {
|
||||
case gomatrixserverlib.BadJSONError:
|
||||
return nil, e
|
||||
} else if err != nil {
|
||||
case gomatrixserverlib.EventValidationError:
|
||||
return nil, e
|
||||
default:
|
||||
return nil, fmt.Errorf("failed to build new %q event: %w", proto.Type, err)
|
||||
}
|
||||
|
||||
// check to see if this user can perform this operation
|
||||
stateEvents := make([]gomatrixserverlib.PDU, len(queryRes.StateEvents))
|
||||
for i := range queryRes.StateEvents {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue