email: Remove special integration doc behavior when gateway not set.

The current code looks like it's trying to redirect /integrations/doc/email
to /integrations when EMAIL_GATEWAY_PATTERN is not set.

I think it doesn't currently do this. The test for that pathway has a bug:
self.get_doc('integrations/doc-html/email', subdomain='zulip') needs a
leading slash, and putting the slash back in results in the test failing.

This redirection is not really desired behavior -- better is to
unconditionally show that the email integration exists, and just point the
user to https://zulip.readthedocs.io/en/latest/production/email-gateway.html
(this is done in a child commit).
This commit is contained in:
Rishi Gupta 2019-08-03 18:08:29 -07:00 committed by Tim Abbott
parent 68dd8e4ec8
commit 8167b5b645
5 changed files with 4 additions and 31 deletions

View File

@ -28,7 +28,7 @@ The default behavior of this integration is designed to be convenient
in the common case. We offer a few options for overriding the default
behavior, configured by editing the Zulip email address:
Example: `{{ email_gateway_example_with_options }}`
Example: `general.abcd1234.show-sender.include-footer@example.zulipchat.com`
* `show-sender`: Will cause `From: <Sender email address>` to be
displayed at the top of Zulip messages sent via this integration.

View File

@ -1,7 +1,6 @@
import os
from typing import Dict, List, Optional, Any
from django.conf import settings
from django.conf.urls import url
from django.contrib.staticfiles.storage import staticfiles_storage
from django.urls.resolvers import LocaleRegexProvider
@ -128,10 +127,6 @@ class BotIntegration(Integration):
doc = self.DEFAULT_DOC_PATH.format(name=name)
self.doc = doc
class EmailIntegration(Integration):
def is_enabled(self) -> bool:
return settings.EMAIL_GATEWAY_PATTERN != ""
class WebhookIntegration(Integration):
DEFAULT_FUNCTION_PATH = 'zerver.webhooks.{name}.view.api_{name}_webhook'
DEFAULT_URL = 'api/v1/external/{name}'
@ -354,8 +349,8 @@ INTEGRATIONS = {
doc='zerver/integrations/codebase.md'),
'discourse': Integration('discourse', 'discourse', ['communication'],
doc='zerver/integrations/discourse.md'),
'email': EmailIntegration('email', 'email', ['communication'],
doc='zerver/integrations/email.md'),
'email': Integration('email', 'email', ['communication'],
doc='zerver/integrations/email.md'),
'errbot': Integration('errbot', 'errbot', ['meta-integration', 'bots'],
doc='zerver/integrations/errbot.md'),
'git': Integration('git', 'git', ['version-control'],

View File

@ -206,17 +206,6 @@ class DocPageTest(ZulipTestCase):
self._test(url, title, doc_html_str=True)
self._test(url, description, doc_html_str=True)
def test_email_integration(self) -> None:
self._test('/integrations/doc-html/email',
'support.abcd1234@testserver', doc_html_str=True)
with self.settings(EMAIL_GATEWAY_PATTERN=''):
result = self.get_doc('integrations/doc-html/email', subdomain='zulip')
self.assertNotIn('support.abcd1234@testserver', str(result.content))
# if EMAIL_GATEWAY_PATTERN is empty, the main /integrations page should
# be rendered instead
self._test('/integrations/', 'native integrations.')
def test_doc_html_str_non_ajax_call(self) -> None:
# We don't need to test all the pages for 404
for integration in list(INTEGRATIONS.keys())[5]:

View File

@ -10,7 +10,7 @@ import random
import re
from zerver.lib.integrations import CATEGORIES, INTEGRATIONS, HubotIntegration, \
WebhookIntegration, EmailIntegration
WebhookIntegration
from zerver.lib.request import has_request_variables, REQ
from zerver.lib.subdomains import get_subdomain
from zerver.models import Realm
@ -193,9 +193,6 @@ def integration_doc(request: HttpRequest, integration_name: str=REQ(default=None
context['integration_url'] = integration.url[3:]
if isinstance(integration, HubotIntegration):
context['hubot_docs_url'] = integration.hubot_docs_url
if isinstance(integration, EmailIntegration):
context['email_gateway_example'] = settings.EMAIL_GATEWAY_EXAMPLE
context['email_gateway_example_with_options'] = settings.EMAIL_GATEWAY_EXAMPLE_WITH_OPTIONS
doc_html_str = render_markdown_path(integration.doc, context)

View File

@ -827,14 +827,6 @@ for bot in INTERNAL_BOTS + REALM_INTERNAL_BOTS + DISABLED_REALM_INTERNAL_BOTS:
bot_email = bot['email_template'] % (INTERNAL_BOT_DOMAIN,)
vars()[bot['var_name']] = bot_email
if EMAIL_GATEWAY_PATTERN != "":
EMAIL_GATEWAY_EXAMPLE = EMAIL_GATEWAY_PATTERN % ("support.abcd1234",)
EMAIL_GATEWAY_EXAMPLE_WITH_OPTIONS = EMAIL_GATEWAY_PATTERN % (
"support.abcd1234.first-option.second-option",)
else:
EMAIL_GATEWAY_EXAMPLE = ""
EMAIL_GATEWAY_EXAMPLE_WITH_OPTIONS = ""
########################################################################
# STATSD CONFIGURATION
########################################################################