Source code for swh.web.inbound_email.views
# Copyright (C) 2024  The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
from django import forms
from django.core.exceptions import ValidationError
from django.http import HttpResponse, HttpResponseBadRequest
from django.utils.crypto import constant_time_compare
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from django.views.generic.edit import FormMixin, ProcessFormView
from ..config import get_config
from .handle_message import MessageHandler
[docs]
class InboundEmailView(FormMixin, ProcessFormView):
    form_class = InboundEmailForm
    success_url = "/"
    http_method_names = ["post", "put"]  # no blank (get) InboundEmailForm view
[docs]
    @method_decorator(csrf_exempt)
    def dispatch(self, *args, **kwargs):
        return super().dispatch(*args, **kwargs)