"""Handle a scan result.""" import config from owsrequest import request import src.sentry as sentry OWS_PODCAST = 'ows-podcast' def is_podcast_ad_read(bucket, key): """Is the podcast an ad read.""" if bucket not in [ 'dev-orcd-podcast-output-assets', 'qa-orcd-podcast-output-assets', 'prod-orcd-podcast-output-assets' ]: return False return key.startswith('copies/') def update_podcast_adread(key): """Update the podcast adread to say pdf is safe.""" response = request.process( application=config.APPLICATION_NAME, environment=config.ENVIRONMENT, method='POST', service_name=OWS_PODCAST, path='/ad-read-virus-free', json={'filename': key} ) if response.status_code != 200: sentry.capture_message( 'ows-podcast error, code {}, body {}, key {}'.format( response.status_code, response.text, key )) def handle_result(bucket, key, result): """Handle the result of the scan based on args.""" if is_podcast_ad_read(bucket, key) and result == 0: update_podcast_adread(key)