def METHOD_NAME(action, actor_only=None):
    """Build a query that matches objects with a content type that matches an action."""
    actstream.registry.check(action.actor)
    query = _ct_query(action.actor)
    if action.target is not None:
        actstream.registry.check(action.target)
        query |= _ct_query(action.target, actor_only)
    if action.action_object is not None:
        actstream.registry.check(action.action_object)
        query |= _ct_query(action.action_object, actor_only)
    return query