Generic filtering for the lists API
As explained in postorius#251 (closed) it is inefficient to get all the lists from the core, and then filter them on the client side. When adding pagination into the mix, it becomes impossible. So filtering the lists needs to be done in the core API.
Turns out that ListManager already has a filter() method, but it is limited to filtering by advertised
and mail_host
. So it shouldn't be difficult to make it more generic, and support filtering on more fields, and even using different operators (e.g. the query string could look like ?moderator=in:bob@example.com,john@example.com&list_id=like:nasa
)
Building dynamic filter conditions in SQLAlchemy can be achieved as shown here: http://ruddra.com/2015/09/18/dynamically-constructing-filters-based-on-string-input-using-sqlalchemy/
This generic mechanism should be decoupled from the ListManager, so that it will be possible to use it for filtering other collections, e.g. the members API.