Only import jinja2/bleach if we need it

This commit is contained in:
Andrew Morgan 2019-06-05 17:27:52 +01:00
parent a4c0907b84
commit efa1a56552

View file

@ -27,7 +27,6 @@ from synapse.http.servlet import (
assert_params_in_dict, assert_params_in_dict,
parse_json_object_from_request, parse_json_object_from_request,
) )
from synapse.push.mailer import Mailer, load_jinja2_templates
from synapse.util.msisdn import phone_number_to_msisdn from synapse.util.msisdn import phone_number_to_msisdn
from synapse.util.stringutils import random_string from synapse.util.stringutils import random_string
from synapse.util.threepids import check_3pid_allowed from synapse.util.threepids import check_3pid_allowed
@ -47,7 +46,11 @@ class EmailPasswordRequestTokenRestServlet(RestServlet):
self.config = hs.config self.config = hs.config
self.identity_handler = hs.get_handlers().identity_handler self.identity_handler = hs.get_handlers().identity_handler
if not hs.config.email_enable_password_reset_from_is: if (
hs.config.enable_password_resets
and not hs.config.email_enable_password_reset_from_is
):
from synapse.push.mailer import Mailer, load_jinja2_templates
templates = load_jinja2_templates( templates = load_jinja2_templates(
config=hs.config, config=hs.config,
template_html_name=hs.config.email_password_reset_template_html, template_html_name=hs.config.email_password_reset_template_html,