mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-17 03:43:11 -06:00
Parse invite room state separately
This commit is contained in:
parent
aba581f3f1
commit
a63c0b3391
|
|
@ -37,10 +37,12 @@ func Invite(
|
|||
producer *producers.RoomserverProducer,
|
||||
keys gomatrixserverlib.KeyRing,
|
||||
) util.JSONResponse {
|
||||
fmt.Println("Receiving invite:", string(request.Content()))
|
||||
|
||||
var intermediate struct {
|
||||
Event json.RawMessage `json:"event"`
|
||||
InviteRoomState []gomatrixserverlib.InviteV2StrippedState `json:"invite_room_state"`
|
||||
RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
|
||||
Event json.RawMessage `json:"event"`
|
||||
InviteRoomState []json.RawMessage `json:"invite_stripped_state"`
|
||||
RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
|
||||
}
|
||||
|
||||
// Unmarshal the request into the intermediate form.
|
||||
|
|
@ -111,11 +113,21 @@ func Invite(
|
|||
string(cfg.Matrix.ServerName), cfg.Matrix.KeyID, cfg.Matrix.PrivateKey,
|
||||
)
|
||||
|
||||
// Try parsing invite states one by one. This allows us to drop only the invite
|
||||
// states that are invalid rather than dropping all of them in one go.
|
||||
inviteStates := []gomatrixserverlib.InviteV2StrippedState{}
|
||||
for _, isj := range intermediate.InviteRoomState {
|
||||
var inviteState gomatrixserverlib.InviteV2StrippedState
|
||||
if err = json.Unmarshal(isj, &inviteState); err == nil {
|
||||
inviteStates = append(inviteStates, inviteState)
|
||||
}
|
||||
}
|
||||
|
||||
// Add the invite event to the roomserver.
|
||||
if err = producer.SendInvite(
|
||||
httpReq.Context(),
|
||||
signedEvent.Headered(intermediate.RoomVersion),
|
||||
intermediate.InviteRoomState,
|
||||
inviteStates,
|
||||
); err != nil {
|
||||
util.GetLogger(httpReq.Context()).WithError(err).Error("producer.SendInvite failed")
|
||||
return jsonerror.InternalServerError()
|
||||
|
|
|
|||
|
|
@ -449,11 +449,6 @@ func (d *SyncServerDatasource) addPDUDeltaToResponse(
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: This should be done in getStateDeltas
|
||||
if err = d.addInvitesToResponse(ctx, txn, device.UserID, fromPos, toPos, res); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
succeeded = true
|
||||
return joinedRoomIDs, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtype
|
|||
logger.WithError(err).Error("rp.currentSyncForUser failed")
|
||||
return jsonerror.InternalServerError()
|
||||
}
|
||||
|
||||
logger.WithField("next", syncData.NextBatch).Info("Responding immediately")
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusOK,
|
||||
|
|
|
|||
Loading…
Reference in a new issue