Merge branch 'master' into neilalexander/rsfsrefactor

This commit is contained in:
Neil Alexander 2022-01-06 09:56:06 +00:00
commit e96bf6178c
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
78 changed files with 1349 additions and 1710 deletions

View file

@ -194,6 +194,12 @@ func SendJoin(
JSON: jsonerror.BadJSON("No state key was provided in the join event."),
}
}
if !event.StateKeyEquals(event.Sender()) {
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.BadJSON("Event state key must match the event sender."),
}
}
// Check that the room ID is correct.
if event.RoomID() != roomID {

View file

@ -175,10 +175,16 @@ func SendLeave(
}
}
if event.StateKey() == nil {
if event.StateKey() == nil || event.StateKeyEquals("") {
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.InvalidArgumentValue("missing state_key"),
JSON: jsonerror.BadJSON("No state key was provided in the leave event."),
}
}
if !event.StateKeyEquals(event.Sender()) {
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.BadJSON("Event state key must match the event sender."),
}
}

View file

@ -371,7 +371,7 @@ func (t *txnReq) processTransaction(ctx context.Context) (*gomatrixserverlib.Res
for _, task := range tasks {
if task.err != nil {
results[task.event.EventID()] = gomatrixserverlib.PDUResult{
Error: task.err.Error(),
// Error: task.err.Error(), TODO: this upsets tests if uncommented
}
} else {
results[task.event.EventID()] = gomatrixserverlib.PDUResult{}
@ -694,6 +694,7 @@ func (t *txnReq) processEvent(ctx context.Context, e *gomatrixserverlib.Event) e
},
api.DoNotSendToOtherServers,
nil,
false,
)
}
@ -829,6 +830,9 @@ func (t *txnReq) processEventWithMissingState(
resolvedState,
backwardsExtremity.Headered(roomVersion),
hadEvents,
// Send the events to the roomserver asynchronously, so they will be
// processed when the roomserver is able, without blocking here.
true,
)
if err != nil {
return fmt.Errorf("api.SendEventWithState: %w", err)
@ -849,6 +853,9 @@ func (t *txnReq) processEventWithMissingState(
append(headeredNewEvents, e.Headered(roomVersion)),
api.DoNotSendToOtherServers,
nil,
// Send the events to the roomserver asynchronously, so they will be
// processed when the roomserver is able, without blocking here.
true,
); err != nil {
return fmt.Errorf("api.SendEvents: %w", err)
}

View file

@ -89,7 +89,7 @@ func CreateInvitesFrom3PIDInvites(
}
// Send all the events
if err := api.SendEvents(req.Context(), rsAPI, api.KindNew, evs, cfg.Matrix.ServerName, nil); err != nil {
if err := api.SendEvents(req.Context(), rsAPI, api.KindNew, evs, cfg.Matrix.ServerName, nil, false); err != nil {
util.GetLogger(req.Context()).WithError(err).Error("SendEvents failed")
return jsonerror.InternalServerError()
}
@ -180,6 +180,7 @@ func ExchangeThirdPartyInvite(
},
cfg.Matrix.ServerName,
nil,
false,
); err != nil {
util.GetLogger(httpReq.Context()).WithError(err).Error("SendEvents failed")
return jsonerror.InternalServerError()