diff --git a/temba/channels/types/mailgun/__init__.py b/temba/channels/types/mailgun/__init__.py deleted file mode 100644 index 247ca8a2082..00000000000 --- a/temba/channels/types/mailgun/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .type import MailgunType # noqa diff --git a/temba/channels/types/mailgun/tests.py b/temba/channels/types/mailgun/tests.py deleted file mode 100644 index 17eecd4cdfd..00000000000 --- a/temba/channels/types/mailgun/tests.py +++ /dev/null @@ -1,61 +0,0 @@ -from django.urls import reverse - -from temba.tests import TembaTest - -from ...models import Channel - - -class MailgunTypeTest(TembaTest): - def test_claim(self): - claim_url = reverse("channels.types.mailgun.claim") - - self.login(self.admin) - - response = self.client.get(reverse("channels.channel_claim")) - self.assertNotContains(response, claim_url) - - self.login(self.customer_support, choose_org=self.org) - - response = self.client.get(reverse("channels.channel_claim")) - self.assertContains(response, claim_url) - - response = self.client.get(claim_url) - self.assertEqual(200, response.status_code) - self.assertEqual({"subject": "Chat with Nyaruka"}, response.context["form"].initial) - - # try to submit with invalid email address - response = self.client.post( - claim_url, - { - "address": "!!!!!!", - "subject": "Chat with Bob", - "sending_key": "0123456789", - "signing_key": "9876543210", - }, - follow=True, - ) - self.assertFormError(response.context["form"], "address", "Enter a valid email address.") - - response = self.client.post( - claim_url, - { - "address": "bob@acme.com", - "subject": "Chat with Bob", - "sending_key": "0123456789", - "signing_key": "9876543210", - }, - follow=True, - ) - self.assertEqual(200, response.status_code) - - channel = Channel.objects.get(channel_type="MLG") - self.assertEqual("bob@acme.com", channel.name) - self.assertEqual("bob@acme.com", channel.address) - self.assertEqual( - { - "auth_token": "0123456789", - "default_subject": "Chat with Bob", - "signing_key": "9876543210", - }, - channel.config, - ) diff --git a/temba/channels/types/mailgun/type.py b/temba/channels/types/mailgun/type.py deleted file mode 100644 index 12af39bff18..00000000000 --- a/temba/channels/types/mailgun/type.py +++ /dev/null @@ -1,43 +0,0 @@ -from django.utils.translation import gettext_lazy as _ - -from temba.contacts.models import URN - -from ...models import ChannelType, ConfigUI -from .views import ClaimView - - -class MailgunType(ChannelType): - """ - A Mailgun email channel. - """ - - code = "MLG" - name = "Mailgun" - category = ChannelType.Category.API - - courier_url = r"^mlg/(?P[a-z0-9\-]+)/receive$" - schemes = [URN.EMAIL_SCHEME] - - claim_blurb = _("Add a %(link)s channel to send and receive messages as emails.") % { - "link": 'Mailgun' - } - claim_view = ClaimView - - config_ui = ConfigUI( - blurb=_( - "To finish configuring this channel, you'll need to add a route for received messages that forwards them." - ), - endpoints=[ - ConfigUI.Endpoint( - courier="receive", - label=_("Receive URL"), - help=_("The URL to forward new emails to."), - ), - ], - ) - - CONFIG_DEFAULT_SUBJECT = "default_subject" - CONFIG_SIGNING_KEY = "signing_key" - - def is_available_to(self, org, user): - return user.is_staff, user.is_staff diff --git a/temba/channels/types/mailgun/views.py b/temba/channels/types/mailgun/views.py deleted file mode 100644 index a8f9a7a4a8e..00000000000 --- a/temba/channels/types/mailgun/views.py +++ /dev/null @@ -1,49 +0,0 @@ -from smartmin.views import SmartFormView - -from django import forms -from django.utils.translation import gettext_lazy as _ - -from ...models import Channel -from ...views import ClaimViewMixin - - -class ClaimView(ClaimViewMixin, SmartFormView): - class Form(ClaimViewMixin.Form): - address = forms.EmailField(label=_("Email Address"), help_text=_("The email address.")) - subject = forms.CharField(label=_("Subject"), help_text=_("The default subject for new emails.")) - sending_key = forms.CharField( - label=_("Sending API key"), - help_text=_("A sending API key you have configured for this domain."), - max_length=50, - ) - signing_key = forms.CharField( - label=_("Webhook Signing key"), - help_text=_("The signing key used for webhook calls."), - max_length=50, - ) - - form_class = Form - - def derive_initial(self): - return {"subject": f"Chat with {self.request.org.name}"} - - def form_valid(self, form): - from .type import MailgunType - - address = form.cleaned_data["address"] - - self.object = Channel.create( - self.request.org, - self.request.user, - None, - self.channel_type, - name=address, - address=address, - config={ - Channel.CONFIG_AUTH_TOKEN: form.cleaned_data["sending_key"], - MailgunType.CONFIG_DEFAULT_SUBJECT: form.cleaned_data["subject"], - MailgunType.CONFIG_SIGNING_KEY: form.cleaned_data["signing_key"], - }, - ) - - return super().form_valid(form) diff --git a/temba/settings_common.py b/temba/settings_common.py index eaf15923c2d..872bf985204 100644 --- a/temba/settings_common.py +++ b/temba/settings_common.py @@ -869,7 +869,6 @@ "temba.channels.types.m3tech.M3TechType", "temba.channels.types.macrokiosk.MacrokioskType", "temba.channels.types.mblox.MbloxType", - "temba.channels.types.mailgun.MailgunType", "temba.channels.types.messagebird.MessageBirdType", "temba.channels.types.messangi.MessangiType", "temba.channels.types.mtn.MtnType",