diff --git a/appservice.py b/appservice.py index e64ff0d..151daf9 100644 --- a/appservice.py +++ b/appservice.py @@ -157,20 +157,20 @@ def new_message(event, user): elif event['content']['msgtype'] == 'm.image': text = event['content']['body'] + "\n" - text += app.config['MATRIX_HOST'] + '/_matrix/media/r0/download/' + event['content']['url'][6:] + text += app.config['MATRIX_URL'] + '/_matrix/media/r0/download/' + event['content']['url'][6:] embed = [raw_from_event(event)] elif event['content']['msgtype'] == 'm.video': text = event['content']['body'] + "\n" - text += app.config['MATRIX_HOST'] + '/_matrix/media/r0/download/' + event['content']['url'][6:] + text += app.config['MATRIX_URL'] + '/_matrix/media/r0/download/' + event['content']['url'][6:] elif event['content']['msgtype'] == 'm.audio': text = event['content']['body'] + "\n" - text += app.config['MATRIX_HOST'] + '/_matrix/media/r0/download/' + event['content']['url'][6:] + text += app.config['MATRIX_URL'] + '/_matrix/media/r0/download/' + event['content']['url'][6:] elif event['content']['msgtype'] == 'm.file': text = event['content']['body'] + "\n" - text += app.config['MATRIX_HOST'] + '/_matrix/media/r0/download/' + event['content']['url'][6:] + text += app.config['MATRIX_URL'] + '/_matrix/media/r0/download/' + event['content']['url'][6:] else: logger.debug('-unknown msg type- ' + event['content']['msgtype']) @@ -208,7 +208,7 @@ def new_message(event, user): def raw_from_event(event): - url = app.config['MATRIX_HOST'] + '/_matrix/media/r0/download/' + event['content']['url'][6:] + url = app.config['MATRIX_URL'] + '/_matrix/media/r0/download/' + event['content']['url'][6:] if event['content']['msgtype'] == 'm.image': value = {'type': "photo", 'version': "1.0"} @@ -224,7 +224,7 @@ def raw_from_event(event): else: value['height'] = 200 if 'thumbnail_info' in event['content']['info']: - value['thumbnail_url'] = app.config['MATRIX_HOST'] + '/_matrix/media/r0/download/' + event['content']['info']['thumbnail_url'][6:] + value['thumbnail_url'] = app.config['MATRIX_URL'] + '/_matrix/media/r0/download/' + event['content']['info']['thumbnail_url'][6:] if 'w' in event['content']['info']['thumbnail_info']: value['thumbnail_width'] = event['content']['info']['thumbnail_info']['w'] else: diff --git a/config.yaml-sample b/config.yaml-sample index 18716e5..d03d148 100644 --- a/config.yaml-sample +++ b/config.yaml-sample @@ -1,6 +1,7 @@ SERVICE_DB: 'sqlite:///store.db' # URL for the service database LISTEN_PORT: 5000 # matrix app service port to listen on -MATRIX_HOST: 'https://localhost:8448' # URL of the matrix server +MATRIX_URL: 'https://' # public base URL of the matrix server +MATRIX_HOST: 'https://localhost:8448' # client URL of the matrix server MATRIX_DOMAIN: '' # domain of the matrix server (right hand side of a matrix ID) MATRIX_AS_ID: '' # matrix ID for the app service user MATRIX_AS_TOKEN: '' # auth token for the app service user