mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-28 16:08:27 +00:00
Clean up
This commit is contained in:
parent
a1091fcfaa
commit
33f8d0e278
2 changed files with 10 additions and 9 deletions
|
@ -54,7 +54,7 @@ func (p *PDUStreamProvider) CompleteSync(
|
||||||
for _, roomID := range joinedRoomIDs {
|
for _, roomID := range joinedRoomIDs {
|
||||||
var jr *types.JoinResponse
|
var jr *types.JoinResponse
|
||||||
jr, err = p.getJoinResponseForCompleteSync(
|
jr, err = p.getJoinResponseForCompleteSync(
|
||||||
ctx, roomID, r, &req.Filter, req.Device,
|
ctx, roomID, r, &req.Filter.Room.State, &req.Filter.Room.Timeline, req.Device,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
req.Log.WithError(err).Error("p.getJoinResponseForCompleteSync failed")
|
req.Log.WithError(err).Error("p.getJoinResponseForCompleteSync failed")
|
||||||
|
@ -74,7 +74,7 @@ func (p *PDUStreamProvider) CompleteSync(
|
||||||
if !peek.Deleted {
|
if !peek.Deleted {
|
||||||
var jr *types.JoinResponse
|
var jr *types.JoinResponse
|
||||||
jr, err = p.getJoinResponseForCompleteSync(
|
jr, err = p.getJoinResponseForCompleteSync(
|
||||||
ctx, peek.RoomID, r, &req.Filter, req.Device,
|
ctx, peek.RoomID, r, &req.Filter.Room.State, &req.Filter.Room.Timeline, req.Device,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
req.Log.WithError(err).Error("p.getJoinResponseForCompleteSync failed")
|
req.Log.WithError(err).Error("p.getJoinResponseForCompleteSync failed")
|
||||||
|
@ -96,7 +96,7 @@ func (p *PDUStreamProvider) CompleteSync(
|
||||||
for _, roomID := range leaveRoomIDs {
|
for _, roomID := range leaveRoomIDs {
|
||||||
var lr *types.LeaveResponse
|
var lr *types.LeaveResponse
|
||||||
lr, err = p.getLeaveResponseForCompleteSync(
|
lr, err = p.getLeaveResponseForCompleteSync(
|
||||||
ctx, roomID, r, &req.Filter, req.Device,
|
ctx, roomID, r, &req.Filter.Room.State, &req.Filter.Room.Timeline, req.Device,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
req.Log.WithError(err).Error("p.getLeaveResponseForCompleteSync failed")
|
req.Log.WithError(err).Error("p.getLeaveResponseForCompleteSync failed")
|
||||||
|
@ -179,7 +179,6 @@ func (p *PDUStreamProvider) addRoomDeltaToResponse(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
recentEvents := p.DB.StreamEventsToEvents(device, recentStreamEvents)
|
recentEvents := p.DB.StreamEventsToEvents(device, recentStreamEvents)
|
||||||
delta.StateEvents = removeDuplicates(delta.StateEvents, recentEvents) // roll back
|
delta.StateEvents = removeDuplicates(delta.StateEvents, recentEvents) // roll back
|
||||||
prevBatch, err := p.DB.GetBackwardTopologyPos(ctx, recentStreamEvents)
|
prevBatch, err := p.DB.GetBackwardTopologyPos(ctx, recentStreamEvents)
|
||||||
|
@ -287,11 +286,12 @@ func (p *PDUStreamProvider) getJoinResponseForCompleteSync(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
roomID string,
|
roomID string,
|
||||||
r types.Range,
|
r types.Range,
|
||||||
filter *gomatrixserverlib.Filter,
|
stateFilter *gomatrixserverlib.StateFilter,
|
||||||
|
eventFilter *gomatrixserverlib.RoomEventFilter,
|
||||||
device *userapi.Device,
|
device *userapi.Device,
|
||||||
) (jr *types.JoinResponse, err error) {
|
) (jr *types.JoinResponse, err error) {
|
||||||
recentEvents, stateEvents, prevBatch, limited, err := p.getResponseForCompleteSync(
|
recentEvents, stateEvents, prevBatch, limited, err := p.getResponseForCompleteSync(
|
||||||
ctx, roomID, r, &filter.Room.State, &filter.Room.Timeline, device,
|
ctx, roomID, r, stateFilter, eventFilter, device,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("p.getResponseForCompleteSync: %w", err)
|
return nil, fmt.Errorf("p.getResponseForCompleteSync: %w", err)
|
||||||
|
@ -309,11 +309,12 @@ func (p *PDUStreamProvider) getLeaveResponseForCompleteSync(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
roomID string,
|
roomID string,
|
||||||
r types.Range,
|
r types.Range,
|
||||||
filter *gomatrixserverlib.Filter,
|
stateFilter *gomatrixserverlib.StateFilter,
|
||||||
|
eventFilter *gomatrixserverlib.RoomEventFilter,
|
||||||
device *userapi.Device,
|
device *userapi.Device,
|
||||||
) (lr *types.LeaveResponse, err error) {
|
) (lr *types.LeaveResponse, err error) {
|
||||||
recentEvents, stateEvents, prevBatch, limited, err := p.getResponseForCompleteSync(
|
recentEvents, stateEvents, prevBatch, limited, err := p.getResponseForCompleteSync(
|
||||||
ctx, roomID, r, &filter.Room.State, &filter.Room.Timeline, device,
|
ctx, roomID, r, stateFilter, eventFilter, device,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("p.getResponseForCompleteSync: %w", err)
|
return nil, fmt.Errorf("p.getResponseForCompleteSync: %w", err)
|
||||||
|
|
|
@ -41,7 +41,7 @@ func newSyncRequest(req *http.Request, device userapi.Device, syncDB storage.Dat
|
||||||
var err error
|
var err error
|
||||||
since, err = types.NewStreamTokenFromString(sinceStr)
|
since, err = types.NewStreamTokenFromString(sinceStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("types.NewStreamTokenFromString: %w", err)
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: read from stored filters too
|
// TODO: read from stored filters too
|
||||||
|
|
Loading…
Reference in a new issue