From 68e6311a9f0f47138c379d5cbea5dbbc2781c0ce Mon Sep 17 00:00:00 2001 From: Matthew Cengia Date: Sun, 11 Apr 2021 16:29:12 +1000 Subject: [PATCH] Update mautrix-twitter config to be Jinja2 template Updates based off the variable names used in mautrix-facebook role. Also update port number in defauts/main.yml, and disable presence checking, because Twitter doesn't support that. --- .../defaults/main.yml | 4 +-- .../templates/config.yaml.j2 | 32 +++++++------------ 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/roles/matrix-bridge-mautrix-twitter/defaults/main.yml b/roles/matrix-bridge-mautrix-twitter/defaults/main.yml index 02eff778..ad162cae 100644 --- a/roles/matrix-bridge-mautrix-twitter/defaults/main.yml +++ b/roles/matrix-bridge-mautrix-twitter/defaults/main.yml @@ -19,7 +19,7 @@ matrix_mautrix_twitter_docker_src_files_path: "{{ matrix_mautrix_twitter_base_pa matrix_mautrix_twitter_homeserver_address: "{{ matrix_homeserver_container_url }}" matrix_mautrix_twitter_homeserver_domain: '{{ matrix_domain }}' -matrix_mautrix_twitter_appservice_address: 'http://matrix-mautrix-twitter:29319' +matrix_mautrix_twitter_appservice_address: 'http://matrix-mautrix-twitter:29327' # A list of extra arguments to pass to the container matrix_mautrix_twitter_container_extra_arguments: [] @@ -72,8 +72,6 @@ matrix_mautrix_twitter_bridge_login_shared_secret_map: "{{ {matrix_mautrix_twitt matrix_mautrix_twitter_appservice_bot_username: twitterbot -matrix_mautrix_twitter_bridge_presence: true - # Default configuration template which covers the generic use case. # You can customize it by controlling the various variables inside it. # diff --git a/roles/matrix-bridge-mautrix-twitter/templates/config.yaml.j2 b/roles/matrix-bridge-mautrix-twitter/templates/config.yaml.j2 index e4f6ba1f..2c10585d 100644 --- a/roles/matrix-bridge-mautrix-twitter/templates/config.yaml.j2 +++ b/roles/matrix-bridge-mautrix-twitter/templates/config.yaml.j2 @@ -1,9 +1,10 @@ +#jinja2: lstrip_blocks: "True" # Homeserver details homeserver: # The address that this appservice can use to connect to the homeserver. - address: https://example.com + address: {{ matrix_mautrix_twitter_homeserver_address }} # The domain of the homeserver (for MXIDs, etc). - domain: example.com + domain: {{ matrix_mautrix_twitter_homeserver_domain }} # Whether or not to verify the SSL certificate of the homeserver. # Only applies if address starts with https:// verify_ssl: true @@ -13,7 +14,7 @@ homeserver: # Changing these values requires regeneration of the registration. appservice: # The address that the homeserver can use to connect to this appservice. - address: http://localhost:29327 + address: {{ matrix_mautrix_twitter_appservice_address }} # When using https:// the TLS certificate and key files for the address. tls_cert: false tls_key: false @@ -26,7 +27,7 @@ appservice: max_body_size: 1 # The full URI to the database. Only Postgres is currently supported. - database: postgres://username:password@hostname/db + database: {{ matrix_mautrix_twitter_appservice_database|to_json }} # Additional arguments for asyncpg.create_pool() # https://magicstack.github.io/asyncpg/current/api/index.html#asyncpg.pool.create_pool database_opts: @@ -47,7 +48,7 @@ appservice: # The unique ID of this appservice. id: twitter # Username of the appservice bot. - bot_username: twitterbot + bot_username: {{ matrix_mautrix_twitter_appservice_bot_username|to_json }} # Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty # to leave display name/avatar as-is. bot_displayname: Twitter bridge bot @@ -65,8 +66,8 @@ appservice: ephemeral_events: false # Authentication tokens for AS <-> HS communication. Autogenerated; do not modify. - as_token: "This value is generated when generating the registration" - hs_token: "This value is generated when generating the registration" + as_token: "{{ matrix_mautrix_twitter_appservice_token }}" + hs_token: "{{ matrix_mautrix_twitter_homeserver_token }}" # Prometheus telemetry config. Requires prometheus-client to be installed. metrics: @@ -99,8 +100,7 @@ bridge: # Allow using double puppeting from any server with a valid client .well-known file. double_puppet_allow_discovery: false # Servers to allow double puppeting from, even if double_puppet_allow_discovery is false. - double_puppet_server_map: - example.com: https://example.com + double_puppet_server_map: {} # Shared secret for https://github.com/devture/matrix-synapse-shared-secret-auth # # If set, custom puppets will be enabled automatically for local users @@ -108,8 +108,7 @@ bridge: # manually. # If using this for other servers than the bridge's server, # you must also set the URL in the double_puppet_server_map. - login_shared_secret_map: - example.com: foo + login_shared_secret_map: {{ matrix_mautrix_twitter_bridge_login_shared_secret_map|to_json }} # Whether or not created rooms should have federation enabled. # If false, created portal rooms will never be federated. federate_rooms: true @@ -181,8 +180,7 @@ bridge: # domain - All users on that homeserver # mxid - Specific user permissions: - "example.com": "user" - "@admin:example.com": "admin" + '{{ matrix_mautrix_twitter_homeserver_domain }}': user # Python logging configuration. @@ -198,12 +196,6 @@ logging: normal: format: "[%(asctime)s] [%(levelname)s@%(name)s] %(message)s" handlers: - file: - class: logging.handlers.RotatingFileHandler - formatter: normal - filename: ./mautrix-twitter.log - maxBytes: 10485760 - backupCount: 10 console: class: logging.StreamHandler formatter: colored @@ -214,4 +206,4 @@ logging: level: INFO root: level: DEBUG - handlers: [file, console] + handlers: [console]