<commit_before>"""Useful utility functions."""


from django.http import HttpResponse
from twilio.twiml import Response

from django_twilio.models import Caller


def get_blacklisted_response(request):
    """Analyze the incoming Twilio request to determine whether or not to
    reject services. We'll only reject services if the user requesting service
    is on our blacklist.

    :param obj request: The Django HttpRequest object to analyze.
    :rtype: HttpResponse.
    :returns: HttpResponse if the user requesting services is blacklisted, None
        otherwise.
    """
    try:
        caller = Caller.objects.get(phone_number=request.POST['From'])
        if caller.blacklisted:
            r = Response()
            r.reject()
            return HttpResponse(str(r), mimetype='application/xml')
    except (KeyError, Caller.DoesNotExist):
        pass

    return None
<commit_msg>Making ``get_blacklisted_response`` work for both GET and POST.<commit_after>"""Useful utility functions."""


from django.http import HttpResponse
from twilio.twiml import Response

from django_twilio.models import Caller


def get_blacklisted_response(request):
    """Analyze the incoming Twilio request to determine whether or not to
    reject services. We'll only reject services if the user requesting service
    is on our blacklist.

    :param obj request: The Django HttpRequest object to analyze.
    :rtype: HttpResponse.
    :returns: HttpResponse if the user requesting services is blacklisted, None
        otherwise.
    """
    try:
        caller = Caller.objects.get(phone_number=request.REQUEST['From'])
        if caller.blacklisted:
            r = Response()
            r.reject()
            return HttpResponse(str(r), mimetype='application/xml')
    except (KeyError, Caller.DoesNotExist):
        pass

    return None

{'fraction_non_alphanumeric': 0.07759088442756376, 'fraction_numerical': 0.0, 'mean_word_length': 3.18140589569161, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5358075', 'n_tokens_mistral': 493, 'n_tokens_neox': 474, 'n_words': 171}