mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-16 11:23:11 -06:00
Merge branch 'master' into neilalexander/stateresv2
This commit is contained in:
commit
e43d8a17ae
|
|
@ -211,7 +211,24 @@ func (t *txnReq) processEventWithMissingState(e gomatrixserverlib.Event) error {
|
|||
return err
|
||||
}
|
||||
// Check that the event is allowed by the state.
|
||||
retryAllowedState:
|
||||
if err := checkAllowedByState(e, state.StateEvents); err != nil {
|
||||
switch missing := err.(type) {
|
||||
case gomatrixserverlib.MissingAuthEventError:
|
||||
// An auth event was missing so let's look up that event over federation
|
||||
for _, s := range state.StateEvents {
|
||||
if s.EventID() != missing.AuthEventID {
|
||||
continue
|
||||
}
|
||||
err = t.processEventWithMissingState(s)
|
||||
// If there was no error retrieving the event from federation then
|
||||
// we assume that it succeeded, so retry the original state check
|
||||
if err == nil {
|
||||
goto retryAllowedState
|
||||
}
|
||||
}
|
||||
default:
|
||||
}
|
||||
return err
|
||||
}
|
||||
// pass the event along with the state to the roomserver
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -8,7 +8,7 @@ require (
|
|||
github.com/matrix-org/go-http-js-libp2p v0.0.0-20200304160008-4ec1129a00c4
|
||||
github.com/matrix-org/go-sqlite3-js v0.0.0-20200304164012-aa524245b658
|
||||
github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200306130050-41bec703d851
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200306154041-df6bb9a3e424
|
||||
github.com/matrix-org/naffka v0.0.0-20200127221512-0716baaabaf1
|
||||
github.com/matrix-org/util v0.0.0-20190711121626-527ce5ddefc7
|
||||
github.com/mattn/go-sqlite3 v2.0.2+incompatible
|
||||
|
|
|
|||
4
go.sum
4
go.sum
|
|
@ -80,8 +80,8 @@ github.com/matrix-org/gomatrix v0.0.0-20190130130140-385f072fe9af/go.mod h1:3fxX
|
|||
github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26 h1:Hr3zjRsq2bhrnp3Ky1qgx/fzCtCALOoGYylh2tpS9K4=
|
||||
github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26/go.mod h1:3fxX6gUjWyI/2Bt7J1OLhpCzOfO/bB3AiX0cJtEKud0=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200124100636-0c2ec91d1df5/go.mod h1:FsKa2pWE/bpQql9H7U4boOPXFoJX/QcqaZZ6ijLkaZI=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200306130050-41bec703d851 h1:cUzTDgLezuL4HKKspoG6W0eq3QiEJRDX6pXsSt28/VE=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200306130050-41bec703d851/go.mod h1:FsKa2pWE/bpQql9H7U4boOPXFoJX/QcqaZZ6ijLkaZI=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200306154041-df6bb9a3e424 h1:H61lT6ckUFIDl9qb636qNomfo0B52lFt73ecioiqF10=
|
||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20200306154041-df6bb9a3e424/go.mod h1:FsKa2pWE/bpQql9H7U4boOPXFoJX/QcqaZZ6ijLkaZI=
|
||||
github.com/matrix-org/naffka v0.0.0-20200127221512-0716baaabaf1 h1:osLoFdOy+ChQqVUn2PeTDETFftVkl4w9t/OW18g3lnk=
|
||||
github.com/matrix-org/naffka v0.0.0-20200127221512-0716baaabaf1/go.mod h1:cXoYQIENbdWIQHt1SyCo6Bl3C3raHwJ0wgVrXHSqf+A=
|
||||
github.com/matrix-org/util v0.0.0-20171127121716-2e2df66af2f5 h1:W7l5CP4V7wPyPb4tYE11dbmeAOwtFQBTW0rf4OonOS8=
|
||||
|
|
|
|||
|
|
@ -119,7 +119,6 @@ type eventStatements struct {
|
|||
bulkSelectEventReferenceStmt *sql.Stmt
|
||||
bulkSelectEventIDStmt *sql.Stmt
|
||||
bulkSelectEventNIDStmt *sql.Stmt
|
||||
selectMaxEventDepthStmt *sql.Stmt
|
||||
}
|
||||
|
||||
func (s *eventStatements) prepare(db *sql.DB) (err error) {
|
||||
|
|
@ -145,7 +144,6 @@ func (s *eventStatements) prepare(db *sql.DB) (err error) {
|
|||
{&s.bulkSelectEventReferenceStmt, bulkSelectEventReferenceSQL},
|
||||
{&s.bulkSelectEventIDStmt, bulkSelectEventIDSQL},
|
||||
{&s.bulkSelectEventNIDStmt, bulkSelectEventNIDSQL},
|
||||
{&s.selectMaxEventDepthStmt, selectMaxEventDepthSQL},
|
||||
}.prepare(db)
|
||||
}
|
||||
|
||||
|
|
@ -488,8 +486,12 @@ func (s *eventStatements) bulkSelectEventNID(ctx context.Context, txn *sql.Tx, e
|
|||
|
||||
func (s *eventStatements) selectMaxEventDepth(ctx context.Context, txn *sql.Tx, eventNIDs []types.EventNID) (int64, error) {
|
||||
var result int64
|
||||
selectStmt := common.TxStmt(txn, s.selectMaxEventDepthStmt)
|
||||
err := selectStmt.QueryRowContext(ctx, eventNIDsAsArray(eventNIDs)).Scan(&result)
|
||||
iEventIDs := make([]interface{}, len(eventNIDs))
|
||||
for i, v := range eventNIDs {
|
||||
iEventIDs[i] = v
|
||||
}
|
||||
sqlStr := strings.Replace(selectMaxEventDepthSQL, "($1)", common.QueryVariadic(len(iEventIDs)), 1)
|
||||
err := txn.QueryRowContext(ctx, sqlStr, iEventIDs...).Scan(&result)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ package routing
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
|
@ -176,6 +177,7 @@ func (r *messagesReq) retrieveEvents() (
|
|||
r.ctx, r.from, r.to, r.roomID, r.limit, r.backwardOrdering,
|
||||
)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("GetEventsInRange: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -226,12 +228,14 @@ func (r *messagesReq) retrieveEvents() (
|
|||
r.ctx, events[0].EventID(),
|
||||
)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("EventPositionInTopology: for start event %s: %s", events[0].EventID(), err)
|
||||
return
|
||||
}
|
||||
endPos, err := r.db.EventPositionInTopology(
|
||||
r.ctx, events[len(events)-1].EventID(),
|
||||
)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("EventPositionInTopology: for end event %s: %s", events[len(events)-1].EventID(), err)
|
||||
return
|
||||
}
|
||||
// Generate pagination tokens to send to the client using the positions
|
||||
|
|
|
|||
Loading…
Reference in a new issue