Fix peeks

This commit is contained in:
Neil Alexander 2021-07-27 13:42:14 +01:00
parent 3eaea0c411
commit 0769412df5
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 20 additions and 28 deletions

View file

@ -27,7 +27,8 @@ func (d *Database) PDUCompleteSync(
defer sqlutil.EndTransactionWithCheck(txn, &succeeded, &err)
for _, roomID := range joinedRoomIDs {
jr, err := d.getJoinResponseForCompleteSync(
var jr *types.JoinResponse
jr, err = d.getJoinResponseForCompleteSync(
ctx, txn, roomID, r, stateFilter, eventFilter, req.WantFullState, req.Device,
)
if err != nil {
@ -38,6 +39,24 @@ func (d *Database) PDUCompleteSync(
req.Rooms[roomID] = gomatrixserverlib.Join
}
peeks, err := d.Peeks.SelectPeeksInRange(ctx, txn, req.Device.UserID, req.Device.ID, r)
if err != nil {
return fmt.Errorf("d.Peeks.SelectPeeksInRange: %w", err)
}
for _, peek := range peeks {
if !peek.Deleted {
var jr *types.JoinResponse
jr, err = d.getJoinResponseForCompleteSync(
ctx, txn, peek.RoomID, r, stateFilter, eventFilter, req.WantFullState, req.Device,
)
if err != nil {
return fmt.Errorf("d.getJoinResponseForCompleteSync: %w", err)
}
req.Response.Rooms.Peek[peek.RoomID] = *jr
}
}
succeeded = true
return nil
}

View file

@ -47,15 +47,6 @@ func (p *PDUStreamProvider) CompleteSync(
return from
}
// Add peeked rooms.
/*
peeks, err := p.DB.PeeksInRange(ctx, req.Device.UserID, req.Device.ID, r)
if err != nil {
req.Log.WithError(err).Error("p.DB.PeeksInRange failed")
return from
}
*/
stateFilter := req.Filter.Room.State
eventFilter := req.Filter.Room.Timeline
@ -64,24 +55,6 @@ func (p *PDUStreamProvider) CompleteSync(
return from
}
/*
for _, peek := range peeks {
p.queue(func() {
if !peek.Deleted {
var jr *types.JoinResponse
jr, err = p.getJoinResponseForCompleteSync(
ctx, peek.RoomID, r, &stateFilter, &eventFilter, req.WantFullState, req.Device,
)
if err != nil {
req.Log.WithError(err).Error("p.getJoinResponseForCompleteSync failed")
return
}
req.Response.Rooms.Peek[peek.RoomID] = *jr
}
})
}
*/
return to
}