<commit_before>import logging

from rest_framework import generics
from rest_framework.request import Request
from rest_framework.response import Response

from manager.signals import email_received

logger = logging.getLogger(__name__)


class EmailsView(generics.GenericAPIView):
    """
    A view for receiving parsed email payloads.
    """

    permission_classes = []

    def post(self, request: Request) -> Response:
        """
        Receive an email.

        Returns an empty response.
        """
        email = request.data
        logger.info(f"Email received from {email.get('from')} to {email.get('to')}")
        email_received.send_robust(sender=self.__class__, email=email)
        return Response()
<commit_msg>fix(Emails): Allow for form/multi-part data<commit_after>import logging

from rest_framework import generics
from rest_framework.parsers import JSONParser, MultiPartParser
from rest_framework.request import Request
from rest_framework.response import Response

from manager.signals import email_received

logger = logging.getLogger(__name__)


class EmailsView(generics.GenericAPIView):
    """
    A view for receiving parsed email payloads.
    """

    permission_classes = []
    parser_classes = [MultiPartParser, JSONParser]

    def post(self, request: Request) -> Response:
        """
        Receive an email.

        Returns an empty response.
        """
        email = request.data
        logger.info(f"Email received from {email.get('from')} to {email.get('to')}")
        email_received.send_robust(sender=self.__class__, email=email)
        return Response()

{'fraction_non_alphanumeric': 0.09231722428748451, 'fraction_numerical': 0.0, 'mean_word_length': 3.473684210526316, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '2958922', 'n_tokens_mistral': 440, 'n_tokens_neox': 427, 'n_words': 120}