mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-18 04:13:10 -06:00
Thwarted by gocyclo again
This commit is contained in:
parent
6cea9e8e67
commit
fe707a163e
|
|
@ -777,6 +777,26 @@ func (d *SyncServerDatasource) addInvitesToResponse(
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Retrieve the backward topology position, i.e. the position of the
|
||||||
|
// oldest event in the room's topology.
|
||||||
|
func (d *SyncServerDatasource) getBackwardTopologyPos(
|
||||||
|
ctx context.Context,
|
||||||
|
events []types.StreamEvent,
|
||||||
|
) (pos types.StreamPosition, err error) {
|
||||||
|
if len(events) > 0 {
|
||||||
|
pos, err = d.topology.selectPositionInTopology(ctx, events[0].EventID())
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if pos-1 <= 0 {
|
||||||
|
pos = types.StreamPosition(1)
|
||||||
|
} else {
|
||||||
|
pos = pos - 1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// addRoomDeltaToResponse adds a room state delta to a sync response
|
// addRoomDeltaToResponse adds a room state delta to a sync response
|
||||||
func (d *SyncServerDatasource) addRoomDeltaToResponse(
|
func (d *SyncServerDatasource) addRoomDeltaToResponse(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
|
|
@ -826,19 +846,10 @@ func (d *SyncServerDatasource) addRoomDeltaToResponse(
|
||||||
prevPDUPos = 1
|
prevPDUPos = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the backward topology position, i.e. the position of the
|
|
||||||
// oldest event in the room's topology.
|
|
||||||
var backwardTopologyPos types.StreamPosition
|
var backwardTopologyPos types.StreamPosition
|
||||||
if len(recentStreamEvents) > 0 {
|
backwardTopologyPos, err = d.getBackwardTopologyPos(ctx, recentStreamEvents)
|
||||||
backwardTopologyPos, err = d.topology.selectPositionInTopology(ctx, recentStreamEvents[0].EventID())
|
if err != nil {
|
||||||
if err != nil {
|
return err
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if backwardTopologyPos-1 <= 0 {
|
|
||||||
backwardTopologyPos = types.StreamPosition(1)
|
|
||||||
} else {
|
|
||||||
backwardTopologyPos = backwardTopologyPos - 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch delta.membership {
|
switch delta.membership {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue