import urllib.request


def check_and_register_sns(request, params):
    """
    Checks if an inbound message is an SNS confirm registration message, and then completes the registration
    :return:
    """
    if params.get('Type', 'None') not in ['SubscriptionConfirmation']:
        ''' Not a subscription request message '''
        return False

    confirmation_url = params.get('SubscribeURL')
    contents = urllib.request.urlopen(confirmation_url).read()
    return True

