Cancel peeks on join again

This commit is contained in:
Neil Alexander 2020-09-04 14:20:00 +01:00
parent 2b8f0b8f59
commit 56d772fafc
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -1129,8 +1129,10 @@ func (d *Database) getStateDeltasForFullStateSync(
}
// Add full states for all peeking rooms
peeking := make(map[string]bool)
newPeeks := false
for _, peek := range peeks {
peeking[peek.RoomID] = true
if peek.New {
newPeeks = true
}
@ -1192,6 +1194,16 @@ func (d *Database) getStateDeltasForFullStateSync(
if stateErr != nil {
return nil, nil, stateErr
}
if peeking[joinedRoomID] {
// we automatically cancel our peeks when we join a room
if err = d.Writer.Do(d.DB, txn, func(txn *sql.Tx) error {
// XXX: is it correct that we're discarding the streamid here?
_, err = d.Peeks.DeletePeeks(ctx, txn, joinedRoomID, userID)
return err
}); err != nil {
return nil, nil, err
}
}
deltas[joinedRoomID] = stateDelta{
membership: gomatrixserverlib.Join,
stateEvents: d.StreamEventsToEvents(device, s),