(message)
This expects message to be the "Message" portion of an AWS SNS Notification as
    sent by Amazon SNS, as described here:
    https://docs.aws.amazon.com/ses/latest/DeveloperGuide/event-publishing-retrieving-sns-examples.html
    :param message:
    :return:
This expects message to be the "Message" portion of an AWS SNS Notification as
    sent by Amazon SNS, as described here:
    https://docs.aws.amazon.com/ses/latest/DeveloperGuide/event-publishing-retrieving-sns-examples.html
    :param message:
    :return:
This expects message to be the Message portion of an AWS SNS Notification as sent by Amazon SNS as described here : https : // docs . aws . amazon . com / ses / latest / DeveloperGuide / event - publishing - retrieving - sns - examples . html : param message : : return :
def handle_email_sns_event(message):
    """
    This expects message to be the "Message" portion of an AWS SNS Notification as
    sent by Amazon SNS, as described here:
    https://docs.aws.amazon.com/ses/latest/DeveloperGuide/event-publishing-retrieving-sns-examples.html
    :param message:
    :return:
    """
    for aws_meta in get_relevant_aws_meta(message):
        if aws_meta.notification_type == NotificationType.BOUNCE:
            if aws_meta.main_type == BounceType.PERMANENT:
                record_permanent_bounce(aws_meta)
                metrics_counter('commcare.email_sns_event.permanent_bounce_recorded')
            elif aws_meta.main_type == BounceType.TRANSIENT:
                record_transient_bounce(aws_meta)
                metrics_counter('commcare.email_sns_event.transient_bounce_recorded')
            elif aws_meta.main_type == BounceType.UNDETERMINED:
                record_permanent_bounce(aws_meta)
                metrics_counter('commcare.email_sns_event.undetermined_bounce_received')
        elif aws_meta.notification_type == NotificationType.COMPLAINT:
            record_complaint(aws_meta)
            metrics_counter('commcare.email_sns_event.complaint_recorded')
    log_email_sns_event(message)
def handle_email_sns_event ( message ) : for aws_meta in get_relevant_aws_meta ( message ) : if aws_meta . notification_type == NotificationType . BOUNCE : if aws_meta . main_type == BounceType . PERMANENT : record_permanent_bounce ( aws_meta ) metrics_counter ( 'commcare.email_sns_event.permanent_bounce_recorded' ) elif aws_meta . main_type == BounceType . TRANSIENT : record_transient_bounce ( aws_meta ) metrics_counter ( 'commcare.email_sns_event.transient_bounce_recorded' ) elif aws_meta . main_type == BounceType . UNDETERMINED : record_permanent_bounce ( aws_meta ) metrics_counter ( 'commcare.email_sns_event.undetermined_bounce_received' ) elif aws_meta . notification_type == NotificationType . COMPLAINT : record_complaint ( aws_meta ) metrics_counter ( 'commcare.email_sns_event.complaint_recorded' ) log_email_sns_event ( message )