N.B. The downstream effects of this are still to be investigated, but the behaviour in and of itself is incorrect so raising this now
Consider the following scenario:
- User jflath has access to channel foo.
- Doc test is created in channels [ foo , bar ].
- Doc test is updated to remove it from channel bar, leaving just foo.
- User jflath is granted access to channel bar.
- User jflath starts a changes feed with no channel filter.
- jflath receives test in the changes feed with Removed:[bar]
- jflath receives test in the changes feed without Removed:[bar]
- jflath also receives test in the changes feed with Removed:[bar]
- Create the user (here done in config):
- Add doc in both channels:
- Remove doc from bar:
- Grant jflath access to bar:
- First check changes from admin perspective - everything looks normal:
- Get changes as jflath, receive two entries for the same doc:
The changes response gives us a good clue - the same doc/rev is listed under 4 and 5:4 - we get the 4 from jflath's access to foo and the 5:4 from the access to bar. We do have handling for the case where a doc has been removed from one of the channels being requested but not others, and check here:
The trouble is the check of cur.Seq == minSeq doesn't work when comparing 4 and 5:4, so they aren't treated as the same entry. My naive fix would be to tweak the check to compare cur.Seq.Seq == minSeq.Seq (i.e. the "real" seq of the doc only, not factoring in the TriggeredBy or LowSeq), but I don't think this would completely fix things based on how we pull items off the current array. It does work for this test case though...