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,9 +37,11 @@ func Invite(
|
||||||
producer *producers.RoomserverProducer,
|
producer *producers.RoomserverProducer,
|
||||||
keys gomatrixserverlib.KeyRing,
|
keys gomatrixserverlib.KeyRing,
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
|
fmt.Println("Receiving invite:", string(request.Content()))
|
||||||
|
|
||||||
var intermediate struct {
|
var intermediate struct {
|
||||||
Event json.RawMessage `json:"event"`
|
Event json.RawMessage `json:"event"`
|
||||||
InviteRoomState []gomatrixserverlib.InviteV2StrippedState `json:"invite_room_state"`
|
InviteRoomState []json.RawMessage `json:"invite_stripped_state"`
|
||||||
RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
|
RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -111,11 +113,21 @@ func Invite(
|
||||||
string(cfg.Matrix.ServerName), cfg.Matrix.KeyID, cfg.Matrix.PrivateKey,
|
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.
|
// Add the invite event to the roomserver.
|
||||||
if err = producer.SendInvite(
|
if err = producer.SendInvite(
|
||||||
httpReq.Context(),
|
httpReq.Context(),
|
||||||
signedEvent.Headered(intermediate.RoomVersion),
|
signedEvent.Headered(intermediate.RoomVersion),
|
||||||
intermediate.InviteRoomState,
|
inviteStates,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
util.GetLogger(httpReq.Context()).WithError(err).Error("producer.SendInvite failed")
|
util.GetLogger(httpReq.Context()).WithError(err).Error("producer.SendInvite failed")
|
||||||
return jsonerror.InternalServerError()
|
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
|
succeeded = true
|
||||||
return joinedRoomIDs, nil
|
return joinedRoomIDs, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtype
|
||||||
logger.WithError(err).Error("rp.currentSyncForUser failed")
|
logger.WithError(err).Error("rp.currentSyncForUser failed")
|
||||||
return jsonerror.InternalServerError()
|
return jsonerror.InternalServerError()
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.WithField("next", syncData.NextBatch).Info("Responding immediately")
|
logger.WithField("next", syncData.NextBatch).Info("Responding immediately")
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusOK,
|
Code: http.StatusOK,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue