For the content repo, don't just use homeserver.hostname as that might not include the port due to SRV.

This commit is contained in:
Erik Johnston 2014-08-24 11:56:55 +01:00
parent 9d86c8c7a6
commit 0c3b4a1f63
2 changed files with 10 additions and 1 deletions

View File

@ -37,6 +37,7 @@ import logging
import logging.config import logging.config
import sqlite3 import sqlite3
import os import os
import re
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -255,8 +256,14 @@ def setup():
logger.info("Server hostname: %s", args.host) logger.info("Server hostname: %s", args.host)
if re.search(":[0-9]+$", args.host):
domain_with_port = args.host
else:
domain_with_port = "%s:%s" % (args.host, args.port)
hs = SynapseHomeServer( hs = SynapseHomeServer(
args.host, args.host,
domain_with_port=domain_with_port,
upload_dir=os.path.abspath("uploads"), upload_dir=os.path.abspath("uploads"),
db_name=db_name, db_name=db_name,
) )

View File

@ -325,7 +325,9 @@ class ContentRepoResource(resource.Resource):
# FIXME (erikj): These should use constants. # FIXME (erikj): These should use constants.
file_name = os.path.basename(fname) file_name = os.path.basename(fname)
url = "http://%s/matrix/content/%s" % (self.hs.hostname, file_name) url = "http://%s/matrix/content/%s" % (
self.hs.domain_with_port, file_name
)
respond_with_json_bytes(request, 200, respond_with_json_bytes(request, 200,
json.dumps({"content_token": url}), json.dumps({"content_token": url}),