#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Coded by L1ghtM3n@protonmail.com

# Import modules
from flask import request

# Show reports only with selected domains
def SearchReports(reports: list) -> list:
    domains = request.args.get("search_domains")
    # If empty
    if domains is None:
        return reports
    # Create empty list and parse domains
    result = []
    domains = domains.lower().split(", ")
    # Find reports
    for report in reports:
        pwds = report.passwords_list.lower()
        for domain in domains:
            if domain in pwds:
                result.append(report)

    return result
