mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-26 06:58:27 +00:00
Tweaks
This commit is contained in:
parent
0769412df5
commit
f2f094e7f0
2 changed files with 10 additions and 3 deletions
|
@ -134,7 +134,7 @@ func (d *Database) addRoomDeltaToResponse(
|
|||
}
|
||||
recentEvents := d.StreamEventsToEvents(device, recentStreamEvents)
|
||||
delta.StateEvents = removeDuplicates(delta.StateEvents, recentEvents) // roll back
|
||||
prevBatch, err := d.GetBackwardTopologyPos(ctx, recentStreamEvents)
|
||||
prevBatch, err := d.getBackwardTopologyPos(ctx, txn, recentStreamEvents)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ func (d *Database) getJoinResponseForCompleteSync(
|
|||
var prevBatch *types.TopologyToken
|
||||
if len(recentStreamEvents) > 0 {
|
||||
var backwardTopologyPos, backwardStreamPos types.StreamPosition
|
||||
backwardTopologyPos, backwardStreamPos, err = d.PositionInTopology(ctx, recentStreamEvents[0].EventID())
|
||||
backwardTopologyPos, backwardStreamPos, err = d.Topology.SelectPositionInTopology(ctx, txn, recentStreamEvents[0].EventID())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -551,12 +551,19 @@ func (d *Database) RedactEvent(ctx context.Context, redactedEventID string, reda
|
|||
func (d *Database) GetBackwardTopologyPos(
|
||||
ctx context.Context,
|
||||
events []types.StreamEvent,
|
||||
) (types.TopologyToken, error) {
|
||||
return d.getBackwardTopologyPos(ctx, nil, events)
|
||||
}
|
||||
|
||||
func (d *Database) getBackwardTopologyPos(
|
||||
ctx context.Context, txn *sql.Tx,
|
||||
events []types.StreamEvent,
|
||||
) (types.TopologyToken, error) {
|
||||
zeroToken := types.TopologyToken{}
|
||||
if len(events) == 0 {
|
||||
return zeroToken, nil
|
||||
}
|
||||
pos, spos, err := d.Topology.SelectPositionInTopology(ctx, nil, events[0].EventID())
|
||||
pos, spos, err := d.Topology.SelectPositionInTopology(ctx, txn, events[0].EventID())
|
||||
if err != nil {
|
||||
return zeroToken, err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue