We have a class that generates an RSS feed to expose questions from a community on a public website. The Visualforce page for the feed uses a custom controller with the following query, which should return all questions that were not posted to private groups:
List <FeedItem> questionList = [SELECT Id, Title, CreatedBy.Name, Body, NetworkScope, ParentId FROM FeedItem WHERE Type = 'QuestionPost' AND ParentId NOT IN (SELECT Id FROM CollaborationGroup WHERE CollaborationType = 'Private') AND NetworkScope != null AND Visibility = 'AllUsers' ORDER BY CreatedDate DESC LIMIT 50];
Guest users on the site are able to see questions asked to private groups even though those feed items should be excluded from the query results. It looks like the inner query (SELECT Id FROM CollaborationGroup WHERE CollaborationType = 'Private') returns null when running as a guest user, which eliminates the filter on private groups.
How can I filter questions made to private groups out of the results?