Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
babolivier committed Aug 1, 2019
1 parent 3ff3dfe commit f25f638
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docs/sample_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ uploads_path: "DATADIR/uploads"
# # Directory in which Synapse will try to find the HTML files to serve to the
# # user when trying to renew an account. Optional, defaults to
# # synapse/res/templates.
# template_dir: "res/templates"
# template_dir: "res/templates"
# # HTML to be displayed to the user after they successfully renewed their
# # account. Optional.
# account_renewed_html_path: "account_renewed.html"
Expand Down
19 changes: 7 additions & 12 deletions synapse/config/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
# limitations under the License.

import os
import pkg_resources

from distutils.util import strtobool

import pkg_resources

from synapse.config._base import Config, ConfigError
from synapse.types import RoomAlias
from synapse.util.stringutils import random_string_with_symbols
Expand Down Expand Up @@ -54,26 +54,21 @@ def __init__(self, config, synapse_config):
template_dir = pkg_resources.resource_filename("synapse", "res/templates")

if "account_renewed_html_path" in config:
file_path = os.path.join(
template_dir, config["account_renewed_html_path"],
)
file_path = os.path.join(template_dir, config["account_renewed_html_path"])

self.account_renewed_html_content = self.read_file(
file_path,
"account_validity.account_renewed_html_path",
file_path, "account_validity.account_renewed_html_path"
)
else:
self.account_renewed_html_content = (
"<html><body>Your account has been successfully renewed.</body><html>"
)

if "invalid_token_html_path" in config:
file_path = os.path.join(
template_dir, config["invalid_token_html_path"],
)
file_path = os.path.join(template_dir, config["invalid_token_html_path"])

self.invalid_token_html_content = self.read_file(
file_path, "account_validity.invalid_token_html_path",
file_path, "account_validity.invalid_token_html_path"
)
else:
self.invalid_token_html_content = (
Expand Down Expand Up @@ -184,7 +179,7 @@ def generate_config_section(self, generate_secrets=False, **kwargs):
# # Directory in which Synapse will try to find the HTML files to serve to the
# # user when trying to renew an account. Optional, defaults to
# # synapse/res/templates.
# template_dir: "res/templates"
# template_dir: "res/templates"
# # HTML to be displayed to the user after they successfully renewed their
# # account. Optional.
# account_renewed_html_path: "account_renewed.html"
Expand Down
6 changes: 2 additions & 4 deletions synapse/rest/client/v2_alpha/account_validity.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def on_GET(self, request):
renewal_token = request.args[b"token"][0]

token_valid = yield self.account_activity_handler.renew_account(
renewal_token.decode("utf8"),
renewal_token.decode("utf8")
)

if token_valid:
Expand All @@ -64,9 +64,7 @@ def on_GET(self, request):

request.setResponseCode(status_code)
request.setHeader(b"Content-Type", b"text/html; charset=utf-8")
request.setHeader(
b"Content-Length", b"%d" % (len(response),)
)
request.setHeader(b"Content-Length", b"%d" % (len(response),))
request.write(response.encode("utf8"))
finish_request(request)
defer.returnValue(None)
Expand Down

0 comments on commit f25f638

Please sign in to comment.