Construct database queries on threads/messages from query parameters.

Summary: Currently only for exact term matching -- no regular expressions yet.

Test Plan: Unit tests to come.

Reviewers: mg, spang

Reviewed By: mg

Differential Revision: https://review.inboxapp.com/D128