Sync gateway how to modify _changes feed, so to exclude "removed":["channel"] messages

I have a sync function that includes the following code:

if(isExplicitlyNotAllowedToBeSynced()){
channel(getDeactivatedDocumentsChannel());
return;
}

function isExplicitlyNotAllowedToBeSynced() {
return (doc.AllowSync === false);
}

I include this in order to be able to exclude some of my docs from sync procedure by means of including field (flag): “AllowSync = false”. By default all of my docs have this field set to “true”.

But I am facing the following problem, when I set AllowSync to “false” all of my clients receive alot of the following rows in _changes feed:

{"results":[

{“seq”:“5027:28”,“id”:“a213f63a-43c7-484d-ab68-24a6b50a9e95”,“removed”:[“schemaChannel”],“changes”:[{“rev”:“1-874126e840e1d3973bd2d289a5afa87e”}]}
,{“seq”:“5027:29”,“id”:“69abeb4d-58f0-4d87-9fc3-e20a2bee217f”,“removed”:[“schemaChannel”],“changes”:[{“rev”:“1-90069d83ac8b96bee6256e280e5a2243”}]}
,{“seq”:“5027:30”,“id”:“dcbd9d3e-8928-4cac-b890-3c32ad5213bc”,“removed”:[“resourcesChannel”],“changes”:[{“rev”:“1-600cd7c99679741529ee2633683aabf9”}]}
,{“seq”:“5027:31”,“id”:“28b2f971-2115-49f0-80cd-1f8afede2952”,“removed”:[“resourcesChannel”],“changes”:[{“rev”:“1-6eef79998549a93c4e45c8834435e3c8”}]}

So if i have alot of documents that belong to channel “resourcesChannel” I got alot of sync work.
Especially it is crucial for new users who have access to this channel and out of the box they have to download those _change feed rows even if they dont have any of those documents before.

Please tell me how to exclude those messages from changes feed for a new users

An initial replication for new users (using Couchbase Lite) is usually run with active_only=true, which will omit removals and tombstones.

Having said that, there’s something a bit unusual about the _changes response you show above. I normally wouldn’t expect a removal for rev 1 of a document - the removed property indicates that a previous revision of the document was in the channel, but the current revision is not. Assuming that’s not just a mocked up response, it suggests that there’s something unexpected going on (possibly unresolved conflicts for that document)?