I need a query that can determine if a particular user has permissions to a file

I’m working on an app (tentatively titled Showcase) that displays recently uploaded files in a gallery above the file view. I’ve got a database table that has a list of some arbitrary number of recently uploaded files, but I only want to display those that have been shared to the currently logged in user.

I’ve been digging around in the database, and I’ve found oc_filecache, but I can’t determine how to check if a specific user has permission to see them. It’s not clear which table or tables to join in to filter for this. There is oc_share, but with single/group permissions and what not I’m sure I can look that up in a simple way.

Can someone point me in the right direction please?