From 67f34a368c814a697890fad933e3d8b61015689a Mon Sep 17 00:00:00 2001 From: Benedikt Tissot Date: Fri, 17 Sep 2021 17:38:47 +0200 Subject: [PATCH 01/11] simplify config generation --- conf/config.yaml | 6 +++--- scripts/_common.sh | 4 ---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/conf/config.yaml b/conf/config.yaml index e1933bf..aec934f 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -424,10 +424,10 @@ bridge: # Telegram config telegram: # Get your own API keys at https://my.telegram.org/apps - api_id: __TELEGRAM_API_ID__ - api_hash: __TELEGRAM_API_HASH__ + api_id: __APIID__ + api_hash: __APIHASH__ # (Optional) Create your own bot at https://t.me/BotFather - bot_token: __TELEGRAM_BOT_TOKEN__ + bot_token: __BOTTOKEN__ # Telethon connection options. connection: diff --git a/scripts/_common.sh b/scripts/_common.sh index d8bd1f0..7a9038d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -21,10 +21,6 @@ write_bridge_config () { verify_server_ssl_certificates="true" matrix_server_supports_asmux="false" log_filename="/var/log/$app/$app.log" - # TODO rename these settings - telegram_api_id="$apiid" - telegram_api_hash="$apihash" - telegram_bot_token="$bottoken" log_level="error" ynh_add_config --template="config.yaml" --destination="$mautrix_config_path" } From fe51aea7047d57e8a4bd4c0bc555d5bcc918c305 Mon Sep 17 00:00:00 2001 From: Benedikt Tissot Date: Fri, 17 Sep 2021 17:53:12 +0200 Subject: [PATCH 02/11] add bot_synapse_adm option --- manifest.json | 15 ++++++++++++++- scripts/install | 12 +++++++----- scripts/upgrade | 11 ++++++----- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/manifest.json b/manifest.json index e7f2f46..abe21ba 100644 --- a/manifest.json +++ b/manifest.json @@ -70,7 +70,20 @@ "fr": "N'activer que si vous connaissez les prérequis et constraintes liées à e2b." }, "default": false - }, + }, + { + "name": "bot_synapse_adm", + "type": "boolean", + "ask": { + "en": "Give the Telegram bot administrator rights to the synapse instance?", + "fr": "Donner au robot Telegram des droits administrateur à l'instance synapse ?" + }, + "help": { + "en": "If true, the bot can group Telegram chats in a Matrix community. Not required if you set up synapse so that non-admins are authorized to create communities.", + "fr": "Si true, le robot groupera les conversations Telegram dans une communauté Matrix. Pas nécessaire si vous avez réglé synapse pour qu'il autorise les non-admin à créer des communautés." + }, + "default": true + }, { "name": "botadmin", "type": "string", diff --git a/scripts/install b/scripts/install index ffb4686..1b05268 100755 --- a/scripts/install +++ b/scripts/install @@ -29,6 +29,7 @@ botname=$YNH_APP_ARG_BOTNAME encryption=$YNH_APP_ARG_ENCRYPTION botadmin=$YNH_APP_ARG_BOTADMIN botusers=$YNH_APP_ARG_BOTUSERS +bot_synapse_adm=$YNH_APP_ARG_BOT_SYNAPSE_ADM # TODO new settings specific to telegram apiid=$YNH_APP_ARG_APIID @@ -90,6 +91,7 @@ ynh_app_setting_set --app=$app --key=server_name --value=$server_name ynh_app_setting_set --app=$app --key=port --value=$port ynh_app_setting_set --app=$app --key=botname --value=$botname ynh_app_setting_set --app=$app --key=synapse_instance --value=$synapse_instance +ynh_app_setting_set --app=$app --key=bot_synapse_adm --value=$bot_synapse_adm ynh_app_setting_set --app=$app --key=app_service_registration_path --value=$app_service_registration_path ynh_app_setting_set --app=$app --key=encryption --value=$encryption ynh_app_setting_set --app=$app --key=mautrix_bridge_db_name --value=$mautrix_bridge_db_name @@ -256,12 +258,12 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" # Wait until the synapse user is created sleep 30 -# # (Note that, by default, non-admins might not have your homeserver's permission to create communities.) -# if [ "$bot_is_synapse_admin" = true ] -# then + # (Note that, by default, non-admins might not have your homeserver's permission to create communities.) + if [ "$bot_synapse_adm" = true ] + then ynh_psql_execute_as_root --database=$synapse_db_name --sql="UPDATE users SET admin = 1 WHERE name = ""$botname"";" -# #yunohost app action run $synapse_instance set_admin_user -a username=$botname -# fi + #yunohost app action run $synapse_instance set_admin_user -a username=$botname + fi ynh_systemd_action --service_name=$app --action="restart" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 8536cfa..864f9ae 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -53,11 +53,12 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # some legacy installs and you therefore want to initiaze stuff during upgrade) # -# If db_name doesn't exist, create it -#if [ -z "$db_name" ]; then -# db_name=$(ynh_sanitize_dbid --db_name=$app) -# ynh_app_setting_set --app=$app --key=db_name --value=$db_name -#fi +bot_synapse_adm=$(ynh_app_setting_get --app=$app --key=bot_synapse_adm) +# If bot_synapse_adm doesn't exist, create it +if [ -z "$bot_synapse_adm" ]; then + bot_synapse_adm=true + ynh_app_setting_set --app=$app --key=bot_synapse_adm --value=$bot_synapse_adm +fi # If final_path doesn't exist, create it #if [ -z "$final_path" ]; then From 7f38927683bd1c49e5fbeb07c629687872a89b62 Mon Sep 17 00:00:00 2001 From: Benedikt Tissot Date: Fri, 17 Sep 2021 17:55:34 +0200 Subject: [PATCH 03/11] add test for upgrading from 0.10.1~ynh3 since newer versions introduce a new option it makes sense to test the legacy upgrade path --- check_process | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/check_process b/check_process index d00c199..b77caa5 100644 --- a/check_process +++ b/check_process @@ -20,12 +20,11 @@ setup_private=0 setup_public=0 upgrade=1 - #upgrade=1 from_commit=636be2f9f900e578d9aa26ee887dcec2ef8d4e71 - #upgrade=1 from_commit=a95215f2ea5d1f34b1c804f776e78c4785477023 + upgrade=1 from_commit=78e25377746ff6a488614c6ea00b8ce7c7e6d88a backup_restore=1 multi_instance=1 port_already_use=1 change_url=0 ;;; Upgrade options -# ; commit=e579544bf977e2b6b4221ecfaf1b1a5c6069560e -# name=0.10.1~ynh3 + ; commit=78e25377746ff6a488614c6ea00b8ce7c7e6d88a + name=0.10.1~ynh3 From 17b7baf47ad9c51f59344c41e8d4c9993fc67ecb Mon Sep 17 00:00:00 2001 From: Benedikt Tissot Date: Fri, 17 Sep 2021 17:59:25 +0200 Subject: [PATCH 04/11] temporary fix to install from webinterface when home is not set pip cannot install the package, therefore set HOME to a well defined path --- scripts/install | 3 +++ scripts/upgrade | 12 +++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index 1b05268..8e7aff2 100755 --- a/scripts/install +++ b/scripts/install @@ -189,6 +189,9 @@ write_bridge_config mkdir -p /var/log/$app # Configure Mautrix-Bridge python3 -m venv $final_path +if [ -z $HOME ]; then + HOME=$final_path # HACK see https://github.com/mautrix/telegram/issues/661 +fi $final_path/bin/pip3 install --upgrade setuptools wheel # HACK fixes "error: invalid command 'bdist_wheel'" $final_path/bin/pip3 install --upgrade $final_path/src/mautrix-telegram.tar.gz[postgres,speedups,qr_login] # metrics,hq_thumbnails,e2be # -r optional-requirements.txt diff --git a/scripts/upgrade b/scripts/upgrade index 864f9ae..5bf6d51 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -122,11 +122,13 @@ ynh_system_user_create --username=$mautrix_bridge_user # ... #================================================= -if [ "$upgrade_type" == "UPGRADE_APP" ] -then -ynh_script_progression --message="Upgrading python packages..." --weight=1 -$final_path/bin/pip3 install --upgrade setuptools wheel # HACK fixes "error: invalid command 'bdist_wheel'" -$final_path/bin/pip3 install --upgrade $final_path/src/mautrix-telegram.tar.gz[postgres,speedups,qr_login] #,hq_thumbnails +if [ "$upgrade_type" == "UPGRADE_APP" ]; then + ynh_script_progression --message="Upgrading python packages..." --weight=1 + if [ -z $HOME ]; then + HOME=$final_path # HACK see https://github.com/mautrix/telegram/issues/661 + fi + $final_path/bin/pip3 install --upgrade setuptools wheel # HACK fixes "error: invalid command 'bdist_wheel'" + $final_path/bin/pip3 install --upgrade $final_path/src/mautrix-telegram.tar.gz[postgres,speedups,qr_login] #,hq_thumbnails fi #================================================= From 1a7f1c55683a72520a08f8b8a6f2d477fc979dee Mon Sep 17 00:00:00 2001 From: Benedikt Tissot Date: Fri, 17 Sep 2021 18:04:55 +0200 Subject: [PATCH 05/11] better indentation --- scripts/install | 12 ++++++------ scripts/upgrade | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/install b/scripts/install index 8e7aff2..ba5f558 100755 --- a/scripts/install +++ b/scripts/install @@ -261,12 +261,12 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" # Wait until the synapse user is created sleep 30 - # (Note that, by default, non-admins might not have your homeserver's permission to create communities.) - if [ "$bot_synapse_adm" = true ] - then - ynh_psql_execute_as_root --database=$synapse_db_name --sql="UPDATE users SET admin = 1 WHERE name = ""$botname"";" - #yunohost app action run $synapse_instance set_admin_user -a username=$botname - fi + +# (Note that, by default, non-admins might not have your homeserver's permission to create communities.) +if [ "$bot_synapse_adm" = true ]; then + ynh_psql_execute_as_root --database=$synapse_db_name --sql="UPDATE users SET admin = 1 WHERE name = ""$botname"";" + #yunohost app action run $synapse_instance set_admin_user -a username=$botname +fi ynh_systemd_action --service_name=$app --action="restart" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 5bf6d51..65acf3c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -62,8 +62,8 @@ fi # If final_path doesn't exist, create it #if [ -z "$final_path" ]; then -# final_path=/var/www/$app -# ynh_app_setting_set --app=$app --key=final_path --value=$final_path +# final_path=/var/www/$app +# ynh_app_setting_set --app=$app --key=final_path --value=$final_path #fi #================================================= From e5d1e26d99916cc468a2e18a6c5f729f08f01567 Mon Sep 17 00:00:00 2001 From: Benedikt Tissot Date: Fri, 17 Sep 2021 18:07:07 +0200 Subject: [PATCH 06/11] new option also required for tests --- check_process | 1 + 1 file changed, 1 insertion(+) diff --git a/check_process b/check_process index b77caa5..5eee6e7 100644 --- a/check_process +++ b/check_process @@ -6,6 +6,7 @@ port="29317" synapsenumber="1" botname="telegrambot" + bot_synapse_adm=true encryption=false botadmin="@johndoe:synapsedomain.tld" botusers="@johndoe:synapsedomain.tld" From 7e6b841b49342975f7d158405c7ccf5c7195f115 Mon Sep 17 00:00:00 2001 From: benneti Date: Sun, 3 Oct 2021 18:59:52 +0200 Subject: [PATCH 07/11] always export home Co-authored-by: Alexandre Aubin --- scripts/install | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index ba5f558..dec91b3 100755 --- a/scripts/install +++ b/scripts/install @@ -189,9 +189,7 @@ write_bridge_config mkdir -p /var/log/$app # Configure Mautrix-Bridge python3 -m venv $final_path -if [ -z $HOME ]; then - HOME=$final_path # HACK see https://github.com/mautrix/telegram/issues/661 -fi +export HOME=$final_path # HACK see https://github.com/mautrix/telegram/issues/661 $final_path/bin/pip3 install --upgrade setuptools wheel # HACK fixes "error: invalid command 'bdist_wheel'" $final_path/bin/pip3 install --upgrade $final_path/src/mautrix-telegram.tar.gz[postgres,speedups,qr_login] # metrics,hq_thumbnails,e2be # -r optional-requirements.txt From a3146ea59d4fce005d6dca548c19a450d44604ad Mon Sep 17 00:00:00 2001 From: Benedikt Tissot Date: Fri, 3 Dec 2021 09:35:20 +0100 Subject: [PATCH 08/11] remove bot_synapse_adm and maintainer + update as I do not use yunohost anymore testing is unnecessary complicated, hopefully someone else wants to go on with maintaining this app --- check_process | 1 - conf/app.src | 4 ++-- manifest.json | 17 ++--------------- scripts/install | 11 ----------- scripts/upgrade | 7 ------- 5 files changed, 4 insertions(+), 36 deletions(-) diff --git a/check_process b/check_process index 5eee6e7..b77caa5 100644 --- a/check_process +++ b/check_process @@ -6,7 +6,6 @@ port="29317" synapsenumber="1" botname="telegrambot" - bot_synapse_adm=true encryption=false botadmin="@johndoe:synapsedomain.tld" botusers="@johndoe:synapsedomain.tld" diff --git a/conf/app.src b/conf/app.src index eced268..49724ac 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/mautrix/telegram/archive/refs/tags/v0.10.1.tar.gz -SOURCE_SUM=81376427d454b6c99c01b244027cd7609d19ef84653625d4027ba92fd5de0466 +SOURCE_URL=https://github.com/mautrix/telegram/archive/refs/tags/v0.10.2.tar.gz +SOURCE_SUM=6c55dd22d71dc8c78a3069acabcd66d8c181c795688f37bfc88fc461e99f5e25 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index abe21ba..13d5662 100644 --- a/manifest.json +++ b/manifest.json @@ -17,8 +17,8 @@ }, "license": "AGPL-3.0-or-later", "maintainer": { - "name": "Benedikt Tissot", - "email": "benedikt.tissot@googlemail.com", + "name": "", + "email": "", "url": "https://github.com/YunoHost-Apps/mautrix_telegram_ynh" }, "requirements": { @@ -71,19 +71,6 @@ }, "default": false }, - { - "name": "bot_synapse_adm", - "type": "boolean", - "ask": { - "en": "Give the Telegram bot administrator rights to the synapse instance?", - "fr": "Donner au robot Telegram des droits administrateur à l'instance synapse ?" - }, - "help": { - "en": "If true, the bot can group Telegram chats in a Matrix community. Not required if you set up synapse so that non-admins are authorized to create communities.", - "fr": "Si true, le robot groupera les conversations Telegram dans une communauté Matrix. Pas nécessaire si vous avez réglé synapse pour qu'il autorise les non-admin à créer des communautés." - }, - "default": true - }, { "name": "botadmin", "type": "string", diff --git a/scripts/install b/scripts/install index dec91b3..7bcefe1 100755 --- a/scripts/install +++ b/scripts/install @@ -29,7 +29,6 @@ botname=$YNH_APP_ARG_BOTNAME encryption=$YNH_APP_ARG_ENCRYPTION botadmin=$YNH_APP_ARG_BOTADMIN botusers=$YNH_APP_ARG_BOTUSERS -bot_synapse_adm=$YNH_APP_ARG_BOT_SYNAPSE_ADM # TODO new settings specific to telegram apiid=$YNH_APP_ARG_APIID @@ -91,7 +90,6 @@ ynh_app_setting_set --app=$app --key=server_name --value=$server_name ynh_app_setting_set --app=$app --key=port --value=$port ynh_app_setting_set --app=$app --key=botname --value=$botname ynh_app_setting_set --app=$app --key=synapse_instance --value=$synapse_instance -ynh_app_setting_set --app=$app --key=bot_synapse_adm --value=$bot_synapse_adm ynh_app_setting_set --app=$app --key=app_service_registration_path --value=$app_service_registration_path ynh_app_setting_set --app=$app --key=encryption --value=$encryption ynh_app_setting_set --app=$app --key=mautrix_bridge_db_name --value=$mautrix_bridge_db_name @@ -257,15 +255,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service ynh_systemd_action --service_name=$app --action="start" -# Wait until the synapse user is created -sleep 30 - -# (Note that, by default, non-admins might not have your homeserver's permission to create communities.) -if [ "$bot_synapse_adm" = true ]; then - ynh_psql_execute_as_root --database=$synapse_db_name --sql="UPDATE users SET admin = 1 WHERE name = ""$botname"";" - #yunohost app action run $synapse_instance set_admin_user -a username=$botname -fi -ynh_systemd_action --service_name=$app --action="restart" #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index 65acf3c..5d80811 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -53,13 +53,6 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # some legacy installs and you therefore want to initiaze stuff during upgrade) # -bot_synapse_adm=$(ynh_app_setting_get --app=$app --key=bot_synapse_adm) -# If bot_synapse_adm doesn't exist, create it -if [ -z "$bot_synapse_adm" ]; then - bot_synapse_adm=true - ynh_app_setting_set --app=$app --key=bot_synapse_adm --value=$bot_synapse_adm -fi - # If final_path doesn't exist, create it #if [ -z "$final_path" ]; then # final_path=/var/www/$app From c2c2696bff3d7e8608fd86152c7aae0adf314594 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 4 Dec 2021 16:28:38 +0100 Subject: [PATCH 09/11] upgrade: export HOME --- scripts/upgrade | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 5d80811..efe9cac 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -117,9 +117,7 @@ ynh_system_user_create --username=$mautrix_bridge_user if [ "$upgrade_type" == "UPGRADE_APP" ]; then ynh_script_progression --message="Upgrading python packages..." --weight=1 - if [ -z $HOME ]; then - HOME=$final_path # HACK see https://github.com/mautrix/telegram/issues/661 - fi + export HOME=$final_path # HACK see https://github.com/mautrix/telegram/issues/661 $final_path/bin/pip3 install --upgrade setuptools wheel # HACK fixes "error: invalid command 'bdist_wheel'" $final_path/bin/pip3 install --upgrade $final_path/src/mautrix-telegram.tar.gz[postgres,speedups,qr_login] #,hq_thumbnails fi From 4460ec4237db7608f27dc6ed92a8c4f68819800d Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 4 Dec 2021 16:29:51 +0100 Subject: [PATCH 10/11] manifest.json: 0.10.1 -> 0.10.2 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 13d5662..2df5204 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Telegram puppeting bridge for Matrix/Synapse", "fr": "Passerelle Telegram pour Matrix/Synapse" }, - "version": "0.10.1~ynh3", + "version": "0.10.2~ynh3", "url": "https://docs.mau.fi/bridges/python/telegram/index.html", "upstream": { "license": "free", From c770586763b8371f9cd468820c221fc37fc11662 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sat, 4 Dec 2021 15:29:54 +0000 Subject: [PATCH 11/11] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2d80dd4..764d25c 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/python/ * see https://docs.mau.fi/bridges/python/telegram/relay-bot.html -**Shipped version:** 0.10.1~ynh3 +**Shipped version:** 0.10.2~ynh3 diff --git a/README_fr.md b/README_fr.md index 914d68b..5612b12 100644 --- a/README_fr.md +++ b/README_fr.md @@ -46,7 +46,7 @@ See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/python/ * see https://docs.mau.fi/bridges/python/telegram/relay-bot.html -**Version incluse :** 0.10.1~ynh3 +**Version incluse :** 0.10.2~ynh3