import json


def check_file_contents_for_email_alerts( app ):
    """
    See if any admin users have chosen to receive email alerts when a repository is updated.
    If so, the file contents of the update must be checked for inappropriate content.
    """
    sa_session = app.model.context.current
    admin_users = app.config.get( "admin_users", "" ).split( "," )
    for repository in sa_session.query( app.model.Repository ) \
                                .filter( app.model.Repository.table.c.email_alerts != None ):
        email_alerts = json.loads( repository.email_alerts )
        for user_email in email_alerts:
            if user_email in admin_users:
                return True
    return False