Fix SQLite problems after sync API changes
parent
ad5849d222
commit
944d454cb0
|
@ -664,6 +664,7 @@ func (d *SyncServerDatasource) getResponseWithPDUsForCompleteSync(
|
||||||
// We don't include a device here as we don't need to send down
|
// We don't include a device here as we don't need to send down
|
||||||
// transaction IDs for complete syncs
|
// transaction IDs for complete syncs
|
||||||
recentEvents := d.StreamEventsToEvents(nil, recentStreamEvents)
|
recentEvents := d.StreamEventsToEvents(nil, recentStreamEvents)
|
||||||
|
stateEvents = removeDuplicates(stateEvents, recentEvents)
|
||||||
jr := types.NewJoinResponse()
|
jr := types.NewJoinResponse()
|
||||||
jr.Timeline.PrevBatch = types.NewPaginationTokenFromTypeAndPosition(
|
jr.Timeline.PrevBatch = types.NewPaginationTokenFromTypeAndPosition(
|
||||||
types.PaginationTokenTypeTopology, backwardTopologyPos, 0,
|
types.PaginationTokenTypeTopology, backwardTopologyPos, 0,
|
||||||
|
@ -803,8 +804,8 @@ func (d *SyncServerDatasource) addInvitesToResponse(
|
||||||
}
|
}
|
||||||
for roomID, inviteEvent := range invites {
|
for roomID, inviteEvent := range invites {
|
||||||
ir := types.NewInviteResponse()
|
ir := types.NewInviteResponse()
|
||||||
ir.InviteState.Events = gomatrixserverlib.ToClientEvents(
|
ir.InviteState.Events = gomatrixserverlib.HeaderedToClientEvents(
|
||||||
[]gomatrixserverlib.Event{inviteEvent.Event}, gomatrixserverlib.FormatSync,
|
[]gomatrixserverlib.HeaderedEvent{inviteEvent}, gomatrixserverlib.FormatSync,
|
||||||
)
|
)
|
||||||
// TODO: add the invite state from the invite event.
|
// TODO: add the invite state from the invite event.
|
||||||
res.Rooms.Invite[roomID] = *ir
|
res.Rooms.Invite[roomID] = *ir
|
||||||
|
@ -856,12 +857,8 @@ func (d *SyncServerDatasource) addRoomDeltaToResponse(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
headeredRecentEvents := d.StreamEventsToEvents(device, recentStreamEvents)
|
recentEvents := d.StreamEventsToEvents(device, recentStreamEvents)
|
||||||
var recentEvents []gomatrixserverlib.Event
|
delta.stateEvents = removeDuplicates(delta.stateEvents, recentEvents)
|
||||||
for _, event := range d.StreamEventsToEvents(nil, recentStreamEvents) {
|
|
||||||
recentEvents = append(recentEvents, event.Event)
|
|
||||||
}
|
|
||||||
delta.stateEvents = removeDuplicates(delta.stateEvents, headeredRecentEvents)
|
|
||||||
backwardTopologyPos := d.getBackwardTopologyPos(ctx, txn, recentStreamEvents)
|
backwardTopologyPos := d.getBackwardTopologyPos(ctx, txn, recentStreamEvents)
|
||||||
|
|
||||||
switch delta.membership {
|
switch delta.membership {
|
||||||
|
@ -871,7 +868,7 @@ func (d *SyncServerDatasource) addRoomDeltaToResponse(
|
||||||
jr.Timeline.PrevBatch = types.NewPaginationTokenFromTypeAndPosition(
|
jr.Timeline.PrevBatch = types.NewPaginationTokenFromTypeAndPosition(
|
||||||
types.PaginationTokenTypeTopology, backwardTopologyPos, 0,
|
types.PaginationTokenTypeTopology, backwardTopologyPos, 0,
|
||||||
).String()
|
).String()
|
||||||
jr.Timeline.Events = gomatrixserverlib.ToClientEvents(recentEvents, gomatrixserverlib.FormatSync)
|
jr.Timeline.Events = gomatrixserverlib.HeaderedToClientEvents(recentEvents, gomatrixserverlib.FormatSync)
|
||||||
jr.Timeline.Limited = false // TODO: if len(events) >= numRecents + 1 and then set limited:true
|
jr.Timeline.Limited = false // TODO: if len(events) >= numRecents + 1 and then set limited:true
|
||||||
jr.State.Events = gomatrixserverlib.HeaderedToClientEvents(delta.stateEvents, gomatrixserverlib.FormatSync)
|
jr.State.Events = gomatrixserverlib.HeaderedToClientEvents(delta.stateEvents, gomatrixserverlib.FormatSync)
|
||||||
res.Rooms.Join[delta.roomID] = *jr
|
res.Rooms.Join[delta.roomID] = *jr
|
||||||
|
@ -884,7 +881,7 @@ func (d *SyncServerDatasource) addRoomDeltaToResponse(
|
||||||
lr.Timeline.PrevBatch = types.NewPaginationTokenFromTypeAndPosition(
|
lr.Timeline.PrevBatch = types.NewPaginationTokenFromTypeAndPosition(
|
||||||
types.PaginationTokenTypeTopology, backwardTopologyPos, 0,
|
types.PaginationTokenTypeTopology, backwardTopologyPos, 0,
|
||||||
).String()
|
).String()
|
||||||
lr.Timeline.Events = gomatrixserverlib.ToClientEvents(recentEvents, gomatrixserverlib.FormatSync)
|
lr.Timeline.Events = gomatrixserverlib.HeaderedToClientEvents(recentEvents, gomatrixserverlib.FormatSync)
|
||||||
lr.Timeline.Limited = false // TODO: if len(events) >= numRecents + 1 and then set limited:true
|
lr.Timeline.Limited = false // TODO: if len(events) >= numRecents + 1 and then set limited:true
|
||||||
lr.State.Events = gomatrixserverlib.HeaderedToClientEvents(delta.stateEvents, gomatrixserverlib.FormatSync)
|
lr.State.Events = gomatrixserverlib.HeaderedToClientEvents(delta.stateEvents, gomatrixserverlib.FormatSync)
|
||||||
res.Rooms.Leave[delta.roomID] = *lr
|
res.Rooms.Leave[delta.roomID] = *lr
|
||||||
|
|
Loading…
Reference in New Issue