diff --git a/bundles/mautrix-telegram/files/registration.yaml b/bundles/mautrix-telegram/files/registration.yaml new file mode 100644 index 0000000..dedca65 --- /dev/null +++ b/bundles/mautrix-telegram/files/registration.yaml @@ -0,0 +1,15 @@ +id: telegram +as_token: ${node.metadata['mautrix-telegram']['as_token']} +hs_token: ${node.metadata['mautrix-telegram']['hs_token']} +namespaces: + users: + - exclusive: true + regex: '@telegram_.+:${node.metadata['mautrix-telegram']['homeserver']['domain']}' + - exclusive: true + regex: '@telegrambot:${node.metadata['mautrix-telegram']['homeserver']['domain']}' + aliases: + - exclusive: true + regex: '#telegram_.+:${node.metadata['mautrix-telegram']['homeserver']['domain']}' +url: http://${node.metadata['mautrix-telegram'].get('listen-addr', '127.0.0.1')}:${node.metadata['mautrix-telegram'].get('port', 21000)} +sender_localpart: ${node.metadata['mautrix-telegram']['sender_localpart']} +rate_limited: false diff --git a/bundles/mautrix-telegram/items.py b/bundles/mautrix-telegram/items.py index 857da7d..4612e76 100644 --- a/bundles/mautrix-telegram/items.py +++ b/bundles/mautrix-telegram/items.py @@ -13,20 +13,9 @@ actions = { 'action:mautrix-telegram_create_virtualenv', }, 'triggers': { - 'action:mautrix-telegram_generate_registration', 'action:mautrix-telegram_upgrade_database', }, }, - 'mautrix-telegram_generate_registration': { - 'command': '/opt/mautrix-telegram/venv/bin/python3 -m mautrix_telegram -c /opt/mautrix-telegram/config.yaml -r /opt/mautrix-telegram/registration.yaml -g', - 'needs': { - 'file:/opt/mautrix-telegram/config.yaml', - }, - 'triggers': { - 'svc_systemd:mautrix-telegram:restart', - }, - 'triggered': True, - }, 'mautrix-telegram_init_alembic': { 'command': '/opt/mautrix-telegram/venv/bin/alembic -c /opt/mautrix-telegram/alembic.ini -x /opt/mautrix-telegram/config.yaml init /opt/mautrix-telegram/alembic', 'unless': 'test -d /opt/mautrix-telegram/alembic', @@ -37,9 +26,6 @@ actions = { 'mautrix-telegram_upgrade_database': { 'command': '/opt/mautrix-telegram/venv/bin/alembic -c /opt/mautrix-telegram/alembic.ini -x /opt/mautrix-telegram/config.yaml upgrade head', 'needs': { - # Actually, the dependency is 'mautrix-telegram has run - # atleast once, but we can't check that. - 'action:mautrix-telegram_generate_registration', 'action:mautrix-telegram_init_alembic', 'postgres_db:mautrix-telegram', 'postgres_role:mautrix-telegram', @@ -51,9 +37,9 @@ actions = { svc_systemd = { 'mautrix-telegram': { 'needs': { - 'action:mautrix-telegram_generate_registration', 'action:mautrix-telegram_upgrade_database', 'file:/etc/systemd/system/mautrix-telegram.service', + 'file:/opt/mautrix-telegram/config.yaml', 'postgres_db:mautrix-telegram', 'postgres_role:mautrix-telegram', }, @@ -61,6 +47,12 @@ svc_systemd = { } files = { + '/opt/mautrix-telegram/registration.yaml': { + 'content_type': 'mako', + 'triggers': { + 'svc_systemd:mautrix-telegram:restart', + }, + }, '/opt/mautrix-telegram/config.yaml': { 'content_type': 'mako', 'triggers': { @@ -76,4 +68,4 @@ files = { } if node.has_bundle('matrix-synapse'): - actions['mautrix-telegram_generate_registration']['triggers'].add('svc_systemd:matrix-synapse:restart') + files['/opt/mautrix-telegram/registration.yaml']['triggers'].add('svc_systemd:matrix-synapse:restart') diff --git a/bundles/mautrix-telegram/metadata.py b/bundles/mautrix-telegram/metadata.py index 5f8e423..c87a499 100644 --- a/bundles/mautrix-telegram/metadata.py +++ b/bundles/mautrix-telegram/metadata.py @@ -16,6 +16,9 @@ defaults = { 'password': repo.vault.password_for('{} postgresql mautrix-telegram'.format(node.name)), 'database': 'mautrix-telegram', }, + 'as_token': repo.vault.password_for('{} mautrix-telegram as_token'.format(node.name)), + 'hs_token': repo.vault.password_for('{} mautrix-telegram hs_token'.format(node.name)), + 'sender_localpart': repo.vault.password_for('{} mautrix-telegram sender_localpart'.format(node.name)), }, 'postgresql': { 'users': { diff --git a/nodes/htz/ex42-1048908.py b/nodes/htz/ex42-1048908.py index b8d2465..be83efe 100644 --- a/nodes/htz/ex42-1048908.py +++ b/nodes/htz/ex42-1048908.py @@ -127,8 +127,6 @@ nodes['htz.ex42-1048908'] = { 'enabled': True, 'shared_secret': vault.decrypt('encrypt$gAAAAABfVKflEMAi07C_QGP8cy97hF-4gGPym0oF6p4WSMdAveTpx-hFsZd2s7v9ubw99yIsyKx0dHOJI0UND7hV1rKZdvjy4Qa642abZ2wwW7SWTqvuP_qVtrf6-klc2QKTzeD9c_LVsyZ2dqz_JxRPq3MRXgkubZuWOZ6FmFlAlteTffoGfWE='), }, - 'as_token': vault.decrypt('encrypt$gAAAAABfVK4eOskBMde8BgmLmMpgr5O1562Ln3qLwCGrW85j57aVkm33-ySWv12ByUoS4U6zU_aTstX1aiRaNgPa76FewNv-Yq9WxNsyxjbpeMdfhX2O9Q5T5RFL4Uple4kJCbOvqDn92U1gAKv2K-RioEGb41iv3Z7usXeyfkny5wa-s8gjICg='), - 'hs_token': vault.decrypt('encrypt$gAAAAABfVK461ryXf-ka8P7x0GQ64O5bBG5-U2mvCzrlS02VGDsLPgNY-_QKd2-GhBtMaYb-OG1KZO_CtCHs54KWQsSDfxJbId4GVpncNDCoDQRnpIvXb0ebdj10-dC3zcANMb9Q2un1psnmgFYawSl4YJLf0_pkQaT13Y1OwWTmHdILUKyAzQU='), 'permissions': { "'*'": 'relaybot', 'nyantec.com': 'full',