From f27c8f76517fc2bfaa0b318ae746ead25f2f591e Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Fri, 17 Feb 2023 06:16:07 +0000 Subject: [PATCH 1/7] Upgrade to v0.8.2 --- conf/amd64.src | 4 ++-- conf/arm64.src | 4 ++-- conf/armhf.src | 4 ++-- manifest.json | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/conf/amd64.src b/conf/amd64.src index e0b3a81..d3dcebc 100644 --- a/conf/amd64.src +++ b/conf/amd64.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.8.1/mautrix-whatsapp-amd64 -SOURCE_SUM=d50af9a4c65593bff3bb3a10382567505cde79929856304f35ae083066955d55 +SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.8.2/mautrix-whatsapp-amd64 +SOURCE_SUM=48cd1fbe1f884a4da789be3abef04c23a61f749901b7666cba794ca1c73046cb SOURCE_SUM_PRG=sha256sum SOURCE_IN_SUBDIR=false SOURCE_FILENAME=mautrix-whatsapp diff --git a/conf/arm64.src b/conf/arm64.src index 4807a62..7c279ec 100644 --- a/conf/arm64.src +++ b/conf/arm64.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.8.1/mautrix-whatsapp-arm64 -SOURCE_SUM=49e1b5308fd8b90e0871b27aa2febc324fbd78c175815312865b54102d04c966 +SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.8.2/mautrix-whatsapp-arm64 +SOURCE_SUM=5ad14583736d1ee148dec5f1ecdeb601af9aeb1797f04c1f1c79fde0cc94a6b0 SOURCE_SUM_PRG=sha256sum SOURCE_IN_SUBDIR=false SOURCE_FILENAME=mautrix-whatsapp diff --git a/conf/armhf.src b/conf/armhf.src index 4a8213c..384b6ff 100644 --- a/conf/armhf.src +++ b/conf/armhf.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.8.1/mautrix-whatsapp-arm -SOURCE_SUM=5f734a40793fc7223b6e15d781f02fae222507c125d12995a85bbb79e1e4370d +SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.8.2/mautrix-whatsapp-arm +SOURCE_SUM=293fc2404bf217a2699a2e58caae717cf0945572c519354c4145da7b9db6d88e SOURCE_SUM_PRG=sha256sum SOURCE_IN_SUBDIR=false SOURCE_FILENAME=mautrix-whatsapp diff --git a/manifest.json b/manifest.json index 3a353cc..4e801fe 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Matrix / Synapse puppeting bridge for WhatsApp", "fr": "Passerelle Matrix / Synapse pour WhatsApp" }, - "version": "0.8.1~ynh1", + "version": "0.8.2~ynh1", "url": "https://github.com/mautrix/whatsapp", "upstream": { "license": "AGPL-3.0-or-later", From 4401652f8665aabea013534b5458b9cdddd664f2 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Fri, 17 Feb 2023 06:16:13 +0000 Subject: [PATCH 2/7] Auto-update README --- README.md | 3 ++- README_fr.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6fbd8bb..f78b602 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ It shall NOT be edited by hand. # Matrix-WhatsApp bridge for YunoHost [![Integration level](https://dash.yunohost.org/integration/mautrix_whatsapp.svg)](https://dash.yunohost.org/appci/app/mautrix_whatsapp) ![Working status](https://ci-apps.yunohost.org/ci/badges/mautrix_whatsapp.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/mautrix_whatsapp.maintain.svg) + [![Install Matrix-WhatsApp bridge with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mautrix_whatsapp) *[Lire ce readme en français.](./README_fr.md)* @@ -24,7 +25,7 @@ Therefore, [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) ** Attention: always backup and restore the Yunohost matrix_synapse et mautrix_whatsapp apps together!** -**Shipped version:** 0.8.1~ynh1 +**Shipped version:** 0.8.2~ynh1 ## Disclaimers / important information ## List of known public services diff --git a/README_fr.md b/README_fr.md index 821a823..a1b2266 100644 --- a/README_fr.md +++ b/README_fr.md @@ -6,6 +6,7 @@ It shall NOT be edited by hand. # Matrix-WhatsApp bridge pour YunoHost [![Niveau d’intégration](https://dash.yunohost.org/integration/mautrix_whatsapp.svg)](https://dash.yunohost.org/appci/app/mautrix_whatsapp) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/mautrix_whatsapp.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/mautrix_whatsapp.maintain.svg) + [![Installer Matrix-WhatsApp bridge avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mautrix_whatsapp) *[Read this readme in english.](./README.md)* @@ -24,7 +25,7 @@ C'est pourquoi [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_y ** Attention : sauvegardez et restaurez toujours les deux applications Yunohost matrix_synapse et mautrix_whatsapp en même temps!** -**Version incluse :** 0.8.1~ynh1 +**Version incluse :** 0.8.2~ynh1 ## Avertissements / informations importantes ## Liste de passerelles publiques From 58773102654581ba5a0f906131bafcc5108b614e Mon Sep 17 00:00:00 2001 From: Dante Date: Wed, 1 Mar 2023 11:20:51 +0000 Subject: [PATCH 3/7] Add new config options --- conf/config.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/conf/config.yaml b/conf/config.yaml index 9d0ede6..caa7287 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -75,6 +75,8 @@ appservice: # Segment API key to track some events, like provisioning API login and encryption errors. segment_key: null +# Optional user_id to use when sending Segment events. If null, defaults to using mxID. +segment_user_id: null # Prometheus config. metrics: @@ -295,10 +297,6 @@ bridge: # Whether or not created rooms should have federation enabled. # If false, created portal rooms will never be federated. federate_rooms: true - # Whether to enable disappearing messages in groups. If enabled, then the expiration time of - # the messages will be determined by the first user to read the message, rather than individually. - # If the bridge only has a single user, this can be turned on safely. - disappearing_messages_in_groups: false # Should the bridge never send alerts to the bridge management room? # These are mostly things like the user being logged out. disable_bridge_alerts: false From 8b710df50305ca2475e2d14f8b705f0c24f7fa24 Mon Sep 17 00:00:00 2001 From: Dante Date: Wed, 1 Mar 2023 19:15:16 +0000 Subject: [PATCH 4/7] Improve remove script by checking PSQL user exists --- scripts/remove | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/scripts/remove b/scripts/remove index f9d9c72..9766f4b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -61,13 +61,22 @@ ynh_remove_logrotate ynh_script_progression --message="Removing the PostgreSQL database..." --weight=4 # Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user=$db_user --db_name=$db_name -ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$app"";" -ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$bot_synapse_db_user"";" -ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$botname"";" -ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$app"";" -ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$bot_synapse_db_user"";" -ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$botname"";" +ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name" + +if ynh_psql_user_exists --user="$app"; then + ynh_psql_execute_as_root --database="$synapse_db_name" --sql="DROP OWNED BY \"$app\";" + ynh_psql_execute_as_root --database="$synapse_db_name" --sql="DROP USER \"$app\";" +fi + +if ynh_psql_user_exists --user="$bot_synapse_db_user"; then + ynh_psql_execute_as_root --database="$synapse_db_name" --sql="DROP OWNED BY \"$bot_synapse_db_user\";" + ynh_psql_execute_as_root --database="$synapse_db_name" --sql="DROP USER \"$bot_synapse_db_user\";" +fi + +if ynh_psql_user_exists --user="$botname"; then + ynh_psql_execute_as_root --database="$synapse_db_name" --sql="DROP OWNED BY \"$botname\";" + ynh_psql_execute_as_root --database="$synapse_db_name" --sql="DROP USER \"$botname\";" +fi #yunohost app action run $synapse_instance drop_user -a username=$botname #================================================= From d8b86980cf6e9d84bb7c1ccd1998295b9f8b2d98 Mon Sep 17 00:00:00 2001 From: Dante Date: Wed, 1 Mar 2023 20:13:23 +0000 Subject: [PATCH 5/7] Improve autoupdater to sync config.yaml --- .githooks/pre-commit | 57 ++++++++++++++++++++++++++++++++++++ .github/workflows/updater.sh | 49 +++++++++++++++++++++++++++++-- doc/DISCLAIMER.md | 9 ++++++ doc/DISCLAIMER_fr.md | 11 +++++++ 4 files changed, 123 insertions(+), 3 deletions(-) create mode 100755 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..4c8bebc --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,57 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=$(git hash-object -t tree /dev/null) +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --type=bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. + +This can cause problems if you want to work with people on other platforms. + +To be portable it is advisable to rename the file. + +If you know what you are doing you can disable this check using: + + git config hooks.allownonascii true +EOF + exit 1 +fi + +# Check if config.yaml has been modified and add a message +git diff --cached --name-only | if grep -q "conf/config.yaml" +then + cat <<\EOF +It seems that you have modified the config.yaml file, consider checking 'SPECIFIC UPDATE STEPS' section of .github/workflows/updater.sh and update there as well if needed" +EOF +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh index ace22df..6b66e32 100755 --- a/.github/workflows/updater.sh +++ b/.github/workflows/updater.sh @@ -19,6 +19,7 @@ repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1] # Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'")) +tarball=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").tarball_url ] | join(" ") | @sh' | tr -d "'") # Later down the script, we assume the version has only digits and dots # Sometimes the release name starts with a "v", so let's filter it out. @@ -86,11 +87,9 @@ tempdir="$(mktemp -d)" # Download sources and calculate checksum filename=${asset_url##*/} curl --silent -4 -L $asset_url -o "$tempdir/$filename" +curl --silent -4 -L $tarball -o "$tempdir/$version" checksum=$(sha256sum "$tempdir/$filename" | head -c 64) -# Delete temporary directory -rm -rf $tempdir - # Rewrite source file cat < conf/$src.src SOURCE_URL=$asset_url @@ -115,6 +114,47 @@ done # Any action on the app's source code can be done. # The GitHub Action workflow takes care of committing all changes after this script ends. +echo "Update latest version of conf/config.yaml" +# Update the config.yaml with the latest version of it and add vars that will be replaced +configFilePath="conf/config-new.yaml" +newConfigFilePath=$(tar -tf "$tempdir/$version" | grep 'example-config.yaml') +tar -xf "$tempdir/$version" --directory "$tempdir" "$newConfigFilePath" +mv "$tempdir/$newConfigFilePath" "$configFilePath" + +# Replace default values with vars that will be replaced on the install script +yq -i '.homeserver.address = "https://__DOMAIN__"' $configFilePath +yq -i '.homeserver.domain = "__SERVER_NAME__"' $configFilePath +yq -i '.homeserver.async_media = "__ASYNC_MEDIA__"' $configFilePath +yq -i '.appservice.address = "http://localhost:__PORT__"' $configFilePath +yq -i '.appservice.port = "__PORT__"' $configFilePath +yq -i '.appservice.database.uri = "postgres://__APP__:__DB_PWD__@localhost:5432/__DB_NAME__"' $configFilePath +yq -i '.appservice.id = "__APPSERVICEID__"' $configFilePath +yq -i '.appservice.bot.username = "__BOTNAME__"' $configFilePath +yq -i '.appservice.bot.displayname = "__DISPLAYNAME__"' $configFilePath +yq -i '.appservice.bot.avatar = "__AVATAR__"' $configFilePath +yq -i '.appservice.ephemeral_events = "__EPHEMERAL_EVENTS__"' $configFilePath +yq -i '.metrics.enabled = "__ENABLE_METRICS__"' $configFilePath +yq -i '.metrics.listen = "__LISTEN_PORT__"' $configFilePath +yq -i '.whatsapp.os_name = "__OS_NAME__"' $configFilePath +yq -i '.whatsapp.browser_name = "__BROWSER_NAME__"' $configFilePath +yq -i '.bridge.username_template = "__USERNAME_TEMPLATE__"' $configFilePath +yq -i '.bridge.personal_filtering_spaces = "__PERSONAL_FILTERING_SPACES__"' $configFilePath +yq -i '.bridge.delivery_receipts = "__DELIVERY_RECEIPTS__"' $configFilePath +yq -i '.bridge.send_presence_on_typing = "__SEND_PRESENCE_ON_TYPING__"' $configFilePath +yq -i '.bridge.url_previews = "__URL_PREVIEWS__"' $configFilePath +yq -i '.bridge.encryption.allow = "__ENCRYPTION__"' $configFilePath +yq -i '.bridge.encryption.default = "__ENCRYPTION_DEFAULT__"' $configFilePath +yq -i '.bridge.encryption.require = "__ENCRYPTION_REQUIRE__"' $configFilePath +yq -i 'with(.bridge.permissions ; . = { "__LISTRELAY__": "relay", "__LISTUSER__": "user", "__LISTADMIN__": "admin" } | ... style="double")' $configFilePath +yq -i '.bridge.relay.enabled = "__ENABLE_RELAYBOT__"' $configFilePath +yq -i '.bridge.relay.admin_only = "__ADMIN_ONLY__"' $configFilePath +yq -i '.logging.directory = "/var/log/__APP__"' $configFilePath +yq -i '.logging.print_level = "__PRINT_LEVEL__"' $configFilePath + +## Keep some default options turned off +yq -i '.logging.file_name_format = "null"' $configFilePath + + #================================================= # GENERIC FINALIZATION #================================================= @@ -122,6 +162,9 @@ done # Replace new version in manifest echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json +# Delete temporary directory +rm -rf $tempdir + # No need to update the README, yunohost-bot takes care of it # The Action will proceed only if the PROCEED environment variable is set to true diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index 735b94b..aed5895 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -92,3 +92,12 @@ In case you need to upload your logs somewhere, be aware that they contain your ``| sed -r 's/[0-9]{10,}/📞/g' `` * "Mautrix-WhatsApp" bridge is based on the [Rhymen/go-whatsapp](https://github.com/Rhymen/go-whatsapp) implementation of the [sigalor/whatsapp-web-reveng](https://github.com/sigalor/whatsapp-web-reveng) project. +## Development code quality + +The `.github/workflows/updater.sh` script needs to be synced with changes in `conf/config.yaml` therefore a `pre-commit` +hook is used to display a reminder to update `.github/workflows/updater.sh` (if needed) when `conf/config.yaml` has been modified. + +Please enable Git hooks using following command to ensure code quality and stability. +``` bash +git config --local core.hooksPath .githooks +``` \ No newline at end of file diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md index cd9208c..5c4a5ad 100644 --- a/doc/DISCLAIMER_fr.md +++ b/doc/DISCLAIMER_fr.md @@ -74,3 +74,14 @@ update-ca-certificates Si vous devez téléverser vos fichiers log quelque-part, soyez avertis qu'ils contiennent des informations sur vos contacts et vos numéros de téléphone. Effacez-les avec ``| sed -r 's/[0-9]{10,}/📞/g' `` * La passerelle "Mautrix-WhatsApp" repose sur l'implémentation [Rhymen/go-whatsapp](https://github.com/Rhymen/go-whatsapp) du projet [sigalor/whatsapp-web-reveng](https://github.com/sigalor/whatsapp-web-reveng). + +## Development code quality + +Le script `.github/workflows/updater.sh` doit être synchronisé avec les changements dans `conf/config.yaml`, +donc un hook `pre-commit` est utilisé pour afficher un rappel pour mettre à jour +`.github/workflows/updater.sh` (si nécessaire) lorsque `conf/config.yaml` a été modifié. + +Veuillez activer les hooks Git en utilisant la commande suivante pour assurer la qualité et la stabilité du code. +``` bash +git config --local core.hooksPath .githooks +``` \ No newline at end of file From 474be40628c298c118e325726d999cfe6394f70c Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Wed, 1 Mar 2023 20:14:01 +0000 Subject: [PATCH 6/7] Auto-update README --- README.md | 8 ++++++++ README_fr.md | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/README.md b/README.md index f78b602..6a36e84 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,15 @@ In case you need to upload your logs somewhere, be aware that they contain your ``| sed -r 's/[0-9]{10,}/📞/g' `` * "Mautrix-WhatsApp" bridge is based on the [Rhymen/go-whatsapp](https://github.com/Rhymen/go-whatsapp) implementation of the [sigalor/whatsapp-web-reveng](https://github.com/sigalor/whatsapp-web-reveng) project. +## Development code quality +The `.github/workflows/updater.sh` script needs to be synced with changes in `conf/config.yaml` therefore a `pre-commit` +hook is used to display a reminder to update `.github/workflows/updater.sh` (if needed) when `conf/config.yaml` has been modified. + +Please enable Git hooks using following command to ensure code quality and stability. +``` bash +git config --local core.hooksPath .githooks +``` ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index a1b2266..851ffbb 100644 --- a/README_fr.md +++ b/README_fr.md @@ -105,6 +105,16 @@ Si vous devez téléverser vos fichiers log quelque-part, soyez avertis qu'ils c ``| sed -r 's/[0-9]{10,}/📞/g' `` * La passerelle "Mautrix-WhatsApp" repose sur l'implémentation [Rhymen/go-whatsapp](https://github.com/Rhymen/go-whatsapp) du projet [sigalor/whatsapp-web-reveng](https://github.com/sigalor/whatsapp-web-reveng). +## Development code quality + +Le script `.github/workflows/updater.sh` doit être synchronisé avec les changements dans `conf/config.yaml`, +donc un hook `pre-commit` est utilisé pour afficher un rappel pour mettre à jour +`.github/workflows/updater.sh` (si nécessaire) lorsque `conf/config.yaml` a été modifié. + +Veuillez activer les hooks Git en utilisant la commande suivante pour assurer la qualité et la stabilité du code. +``` bash +git config --local core.hooksPath .githooks +``` ## Documentations et ressources * Site officiel de l’app : From 349d93c993c65bf78f9bb97c42e57d7c90c78c8d Mon Sep 17 00:00:00 2001 From: Dante Date: Wed, 1 Mar 2023 20:17:39 +0000 Subject: [PATCH 7/7] Fix wrong config filename --- .github/workflows/updater.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh index 6b66e32..de8f362 100755 --- a/.github/workflows/updater.sh +++ b/.github/workflows/updater.sh @@ -116,7 +116,7 @@ done echo "Update latest version of conf/config.yaml" # Update the config.yaml with the latest version of it and add vars that will be replaced -configFilePath="conf/config-new.yaml" +configFilePath="conf/config.yaml" newConfigFilePath=$(tar -tf "$tempdir/$version" | grep 'example-config.yaml') tar -xf "$tempdir/$version" --directory "$tempdir" "$newConfigFilePath" mv "$tempdir/$newConfigFilePath" "$configFilePath"