diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh index 4e85e56..253aacc 100755 --- a/.github/workflows/updater.sh +++ b/.github/workflows/updater.sh @@ -14,8 +14,8 @@ #================================================= # Fetching information -current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') -repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') +current_version=$(yq ".version" manifest.toml | cut -d '~' -f 1 -) +repo=$(yq ".upstream.code" manifest.toml | sed 's/https:\/\/github.com\///') # 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 "'")) @@ -31,9 +31,9 @@ fi # Setting up the environment variables echo "Current version: $current_version" echo "Latest release from upstream: $version" -echo "VERSION=$version" >> $GITHUB_ENV +echo "VERSION=$version" >> "$GITHUB_ENV" # For the time being, let's assume the script will fail -echo "PROCEED=false" >> $GITHUB_ENV +echo "PROCEED=false" >> "$GITHUB_ENV" # Proceed only if the retrieved version is greater than the current one if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then @@ -91,15 +91,8 @@ curl --silent -4 -L $tarball -o "$tempdir/$version" checksum=$(sha256sum "$tempdir/$filename" | head -c 64) # Rewrite source file -cat < conf/$src.src -SOURCE_URL=$asset_url -SOURCE_SUM=$checksum -SOURCE_SUM_PRG=sha256sum -SOURCE_IN_SUBDIR=false -SOURCE_FILENAME=mautrix-whatsapp -SOURCE_EXTRACT=false -EOT -echo "... conf/$src.src updated" +sed -i "s|$src.url.*|src.url = \"$asset_url\"|g" manifest.toml +sed -i "s|$src.sha256.*|$src.sha256 = \"$checksum\"|g" manifest.toml else echo "... asset ignored" @@ -107,6 +100,8 @@ fi done +echo "manifest.toml assets updated" + #================================================= # SPECIFIC UPDATE STEPS #================================================= @@ -148,7 +143,7 @@ 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.writers.filename = "/var/log/__APP__/__APP__.log"' $configFilePath +yq -i '.logging.writers[1].filename = "/var/log/__APP__/__APP__.log"' $configFilePath yq -i '.logging.min_level = "__PRINT_LEVEL__"' $configFilePath #================================================= @@ -156,7 +151,7 @@ yq -i '.logging.min_level = "__PRINT_LEVEL__"' $configFilePath #================================================= # Replace new version in manifest -echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json +sed -i "s|version.*|version = \"$version~ynh1\"|g" manifest.toml # Delete temporary directory rm -rf $tempdir diff --git a/README.md b/README.md index dcff677..4139d18 100644 --- a/README.md +++ b/README.md @@ -26,111 +26,6 @@ Therefore, [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) **Shipped version:** 0.9.0~ynh1 -## Disclaimers / important information - -## List of known public services - -* Ask on one of the following rooms: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net - -## Bridging usage -** Note that several WhatsApp and Matrix users can be bridged, each WhatsApp account has its own bot administration room. If they are in a same WhatsApp group, only one matrix room will be created. ** - -### Bridge a WhatsApp user and a Matrix user -* First your matrix user or server has to be authorized in the bridge configuration (see below) -* Then, invite the bot (default @whatsappbot:yoursynapse.domain) -* The room with the Mautrix-WhatsApp bot is called "administration room". -* Type ``login`` -* Capture the QR code with the camera in the whatsapp of your VM or smartphone (WhatsApp Web) -* Send ``help`` to the bot in the created room to know how to control the bot. -See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/go/whatsapp/authentication.html) - -### Bridge an existing room | Bridge Whatsapp to Signal over Matrix -By default, the bridge creates a portal room for each WA group that the WA user actively uses. -Your can also create a portal for an existing Matrix room. **Note that this can be a room created by another bridge, e.g. a Signal portal room** -1. Invite the bridge bot to the room (with an authorized user) -2. type `!wa create` -3. Your logged in WA user creates a new corresponding group. -4. Get the WA invite link `!wa invite-link` and share it with friends. Or invite Whatsapp puppets to room. -5. Optional: Activate relaybot, see next section. - -### Relaybot: Bridge a group for several Matrix and several WhatsApp users to chat together -**When upgrading from /dev/null | awk '/-----BEGIN CERTIFICATE-----/, /-----END CERTIFICATE-----/' >> /usr/local/share/ca-certificates/synapse.vm.crt -update-ca-certificates -``` - -### Miscellaneous information - - * Matrix room (matrix bridges in YunoHost): #mautrix_yunohost:matrix.fdn.fr - * Matrix room (upstream app): #whatsapp:maunium.net -In case you need to upload your logs somewhere, be aware that they contain your contacts' and your phone numbers. Strip them out with -``| 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 b3e6656..fb5b4e2 100644 --- a/README_fr.md +++ b/README_fr.md @@ -26,95 +26,6 @@ C'est pourquoi [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_y **Version incluse :** 0.9.0~ynh1 -## Avertissements / informations importantes - -## Liste de passerelles publiques - -* Demandez sur un des salons suivants: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net - -## Usages de la passerelle -** Notez que plusieurs comptes WhatsApp et Matrix peuvent ĂȘtre relayĂ©s, chaque compte WhatsApp connectĂ© a son propre Salon d'Administration. Si plusieurs utilisateur.ice.s du Robot sont dans un mĂȘme groupe WhatsApp, seul un Salon Matrix sera créé par la passerelle. ** - -### Relayer TOUTES les conversations entre UN compte WhatsApp et UN compte Matrix -* PrĂ©requis : votre compte Matrix ou le serveur sur lequel il est hĂ©bergĂ© doit ĂȘtre autorisĂ© dans la configuration de la passerelle (voir ci-dessous) -* Invitez le Robot (par dĂ©faut @whatsappbot:synapse.votredomaine) Ă  une nouvelle conversation. -* Ce nouveau salon d'administration du Robot Mautrix-WhatsApp est appelĂ© "Administration Room". -* Tapez ``login`` -* Scannez le QR-code avec la camĂ©ra Whatsapp de votre Machine Virtuelle ou ordiphone (option WhatsApp Web dans l'appli) -* Envoyez ``help`` au Robot dans le "Administration Room" pour une liste des commandes d'administration de la passerelle. -Voir aussi [upstream wiki Authentication page](https://docs.mau.fi/bridges/go/whatsapp/authentication.html) - -#### Robot-Relai "Relaybot": Relayer les conversations de TOUS les comptes Matrix et TOUS les comptes WhatsApp prĂ©sents dans UN groupe/salon - -* PrĂ©requis : CrĂ©er un nouveau salon vide "Relaybot Administration Room" et rechercher son identifiant. -* Activer l'option Robot-Relai "Relaybot" dans la configuration de la passerelle (default=disabled, voir ci-dessous) et ajouter l'identifiant du salon d'administration du Relaybot "Relaybot Administration Room". -* RedĂ©marrer le service mautrix_whatsapp -* Vous pouvez maintenant relayer un groupe WhatsApp en y invitant le numĂ©ro de tĂ©lĂ©phone du compte WhatsApp connectĂ© au RobotRelai. CĂŽtĂ© WhatsApp, tous les messages venant de Matrix seront vus comme envoyĂ©s depuis le compte WhatsApp connectĂ©, avec un prĂ©fix indiquant le compte Matrix correspondant. CĂŽtĂ© Matrix, la passerelle va crĂ©er des comptes Matrix pour chaque compte WhatsApp prĂ©sent dans le groupe relayĂ©. Les messages sont indiquĂ©s comme provenant soit du numĂ©ro de tĂ©lĂ©phone, soit du pseudo WhatsApp. -Voir aussi [la page wiki principale sur le Robot-Relai](https://docs.mau.fi/bridges/go/whatsapp/relaybot.html) - -### Configuration de la passerelle - -La passerelle est [configurĂ©e avec les paramĂštres standards adaptĂ©s pour votre YunoHost et l'instance Matrix-Synapse sĂ©lectionnĂ©e](https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh/blob/master/conf/config.yaml). Vous pouvez par exemple ajouter des administrateur.ice.s et utilisateur.ice.s du Robot autorisĂ©s en modifiant le fichier de configuration par liaison SSH: -``` sudo nano /opt/yunohost/mautrix_whatsapp/config.yaml``` -puis en redĂ©marrant le service: -``` sudo yunohost service restart mautrix_whatsapp``` - -#### End-to-bridge encryption -Le robot peut Ă©ventuellement chiffrer les messages entre les utilisateurs de Matrix et la passarelle pour cacher les messages du serveur domestique. L'utilisation de Postgres est fortement recommandĂ©e lors de l'utilisation du chiffrement end-to-bridge. - -Si vous voulez l'activer, cherchez l'option ```bridge → encryption``` dans le fichier de configuration. Si vous dĂ©finissez uniquement l'option ``allow: true``, le robot n'activera pas le chiffrement de lui-mĂȘme, mais travaillera dans les portails chiffrĂ©s. Si vous dĂ©finissez ```default: true```, la passerelle activera automatiquement le chiffrement dans les nouveaux portails. -Il y a Ă©galement la possibilitĂ© de dĂ©finir ```require: true``` pour imposer le chiffrement sur tous les messages que vous envoyez (cela interdira tous les messages non chiffrĂ©s). - -### Support multi-comptes - -* Les utilisateur.ice.s du Robot ne sont pas liĂ©s aux comptes Yunohost. N'importe quel compte Matrix ou serveur Synapse autorisĂ©s dans la configuration de la passerelle peut inviter/utiliser le Robot. -* Le robot WhatsApp est un utilisateur Matrix-Synapse local, mais accessible via la fĂ©dĂ©ration (Synapse public ou privĂ©). -* Plusieurs comptes WhatsApp et Matrix peuvent ĂȘtre liĂ©s avec une seule passerelle, chaque compte a son propre salon d'administration. -* Si plusieurs utilisateur.ice.s du Robot sont dans un mĂȘme groupe WhatsApp, seul un Salon Matrix sera créé par la passerelle. Autrement dit, la passerelle construit un seul miroir du rĂ©seau de discussion existant sur WhatsApp (utilisateurs et salons). -* Voir https://github.com/YunoHost-Apps/synapse_ynh#multi-users-support - -### Support multi-instance - -* L'installation multi-instance devrait fonctionner. Plusieurs instances de passerelles pourraient ĂȘtre installĂ©es pour une instance de Matrix-Synapse. Cela permet Ă  un compte matrix de se relier Ă  plusieurs comptes WhatsApp. -* Plusieurs instances de passerelles pourraient ĂȘtre installĂ©es pour que chaque instance de Matrix-Synapse puisse en bĂ©nĂ©ficier. Mais une passerelle peut ĂȘtre utilisĂ©e par les comptes de plusieurs instances Matrix-Synapse. - -### Architectures supportĂ©es - -ARM, ARM64, AMD64 - -### Limitations - -* Les appels Audio/Video ne sont pas relayĂ©s. Seule une notification apparait. -* Si WhatsApp perd la connexion, par ex. l'ordiphone est mis en mode avion ou les notifications poussĂ©es sont dĂ©sactivĂ©es, le robot doit parfois ĂȘtre redĂ©marrĂ© Ă  la main en envoyant un message ``wa !reconnnect`` dans le salon d'administration. - -### Informations additionnelles - -* Il est recommandĂ© d'installer WhatsApp sur une machine Android virtuelle tournant sur un serveur, cf. le [page Android-VM-Setup du wiki](https://docs.mau.fi/bridges/go/whatsapp/android-vm-setup.html) - -Pour tester la communication entre le Service d'Application et Matrix-Synapse sur une Machine Virtuelle (ex. avec un nom de domaine: synapse.vm), vous devez installer un certificat: -``` -echo | openssl s_client -showcerts -servername synapse.vm -connect synapse.vm:443 2>/dev/null | awk '/-----BEGIN CERTIFICATE-----/, /-----END CERTIFICATE-----/' >> /usr/local/share/ca-certificates/synapse.vm.crt -update-ca-certificates -``` - -### Informations diverses - -* Salon Matrix sur les Passerelles dans Yunohost): #mautrix_yunohost:matrix.fdn.fr -* Salon Matrix (application principale): #whatsapp:maunium.net -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 -``` ## Documentations et ressources * Site officiel de l’app : diff --git a/check_process b/check_process deleted file mode 100644 index a30309e..0000000 --- a/check_process +++ /dev/null @@ -1,33 +0,0 @@ -;; Default test serie - ; pre-install - sudo yunohost tools update apps - sudo yunohost app install https://github.com/YunoHost-Apps/synapse_ynh/ -a "domain=$domain&server_name=$server_name&is_free_registration=$is_free_registration&jitsi_server=$jitsi_server" --force - ; Manifest - synapsenumber="1" - whatsappbot="whatsappbot" - bot_synapse_adm=0 - encryption=0 - botadmin="@johndoe:synapsedomain.tld" - botusers="@johndoe:synapsedomain.tld" - ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=0 - setup_nourl=1 - setup_private=0 - setup_public=0 - upgrade=1 - # 0.4.0 - upgrade=1 from_commit=717b32f454819c1bb936152c69d9693d34434741 - # 0.6.1 - upgrade=1 from_commit=fdd1e0ff652ae47b5e3c62477eea678c465659cf - backup_restore=1 - multi_instance=1 -;;; Options -Email= -Notification=none -;;; Upgrade options - ; commit=717b32f454819c1bb936152c69d9693d34434741 - name=0.4.0 - ; commit=fdd1e0ff652ae47b5e3c62477eea678c465659cf - name=0.6.1 diff --git a/conf/amd64.src b/conf/amd64.src deleted file mode 100644 index 05fc4c2..0000000 --- a/conf/amd64.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.9.0/mautrix-whatsapp-amd64 -SOURCE_SUM=27b5d3ee0cada177207b662072b42923956e38a9c10c4e167eeca17881f3bffb -SOURCE_SUM_PRG=sha256sum -SOURCE_IN_SUBDIR=false -SOURCE_FILENAME=mautrix-whatsapp -SOURCE_EXTRACT=false diff --git a/conf/arm64.src b/conf/arm64.src deleted file mode 100644 index cd25bd8..0000000 --- a/conf/arm64.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.9.0/mautrix-whatsapp-arm64 -SOURCE_SUM=dc475a2af45988d6d428af18c5f2a30da24930201e0e667a0b749a198a3bd02d -SOURCE_SUM_PRG=sha256sum -SOURCE_IN_SUBDIR=false -SOURCE_FILENAME=mautrix-whatsapp -SOURCE_EXTRACT=false diff --git a/conf/armhf.src b/conf/armhf.src deleted file mode 100644 index c950428..0000000 --- a/conf/armhf.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.9.0/mautrix-whatsapp-arm -SOURCE_SUM=22c28d17ec868c4579e8ed64e092b0947a268c82ed9714d3ae45ace05b477fd8 -SOURCE_SUM_PRG=sha256sum -SOURCE_IN_SUBDIR=false -SOURCE_FILENAME=mautrix-whatsapp -SOURCE_EXTRACT=false diff --git a/conf/systemd.service b/conf/systemd.service index bee8791..0e8c08b 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,13 +6,13 @@ After=matrix-synapse.service Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/mautrix-whatsapp -c=__FINALPATH__/config.yaml +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=__INSTALL_DIR__/mautrix-whatsapp -c=__INSTALL_DIR__/config.yaml Restart=always RestartSec=3 # Optional hardening to improve security -ReadWritePaths=__FINALPATH__/ /var/log/__APP__ +ReadWritePaths=__INSTALL_DIR__/ /var/log/__APP__ NoNewPrivileges=yes MemoryDenyWriteExecute=true PrivateDevices=yes diff --git a/config_panel.toml b/config_panel.toml index a691864..8e53315 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -42,7 +42,7 @@ services = ["__APP__"] yes = "true" no = "false" help = "If allowed, '!wa set-relay' can be used to turn any Bridge User into a RelayBot for that chat. This allows people to talk on WhatsApp without an own account." - bind = "relay>enabled:__FINALPATH__/config.yaml" + bind = "relay>enabled:__INSTALL_DIR__/config.yaml" [main.bridge.admin_only] ask = "Should only Bridge Admins be allowed to set themselves as Relay Users?" @@ -50,7 +50,7 @@ services = ["__APP__"] yes = "true" no = "false" help = "See User management -> Admins" - bind = ":__FINALPATH__/config.yaml" + bind = ":__INSTALL_DIR__/config.yaml" visible = "enable_relaybot" [main.bot] @@ -60,19 +60,19 @@ services = ["__APP__"] ask = "Username of the AppService Bot" type = "string" help = "Sets bot username. Please keep in mind that the bot admin room for previous bot username will stop working so you may need to create a new one using the new username" - bind = "bot>username:__FINALPATH__/config.yaml" + bind = "bot>username:__INSTALL_DIR__/config.yaml" [main.bot.displayname] ask = "Display name for Bot" type = "string" help = "Set to 'remove' to remove display name, leave empty to set default 'WhatsApp bridge bot'" - bind = ":__FINALPATH__/config.yaml" + bind = ":__INSTALL_DIR__/config.yaml" [main.bot.avatar] ask = "Avatar for Bot" type = "string" help = "Should be in format 'mxc://server_name/NeXNQarUbrlYBiPCpprYsRqr', see README for tutorial. Set to 'remove' to remove avatar, leave empty to use standard WhatsApp logo." - bind = ":__FINALPATH__/config.yaml" + bind = ":__INSTALL_DIR__/config.yaml" [privacy] name = "Privacy" @@ -95,7 +95,7 @@ services = ["__APP__"] yes = "true" no = "false" help = "Enable so-called End-to-Bridge (e2b) Encryption. For the Bridge to work in group chat Rooms with End-to-End Encryption (e2ee) enabled." - bind = "encryption>allow:__FINALPATH__/config.yaml" + bind = "encryption>allow:__INSTALL_DIR__/config.yaml" [privacy.portal_rooms.encryption_default] ask = "Force-enable Encryption in all Portal Rooms the Bridge creates?" @@ -103,7 +103,7 @@ services = ["__APP__"] yes = "true" no = "false" help = "This will cause the Bridge Bot to be in private chats for the Encryption to work properly." - bind = "encryption>default:__FINALPATH__/config.yaml" + bind = "encryption>default:__INSTALL_DIR__/config.yaml" visible = "encryption" [privacy.portal_rooms.encryption_require] @@ -112,7 +112,7 @@ services = ["__APP__"] yes = "true" no = "false" help = "Require encryption, drop any unencrypted messages." - bind = "encryption>require:__FINALPATH__/config.yaml" + bind = "encryption>require:__INSTALL_DIR__/config.yaml" visible = "encryption" [privacy.config] @@ -124,7 +124,7 @@ services = ["__APP__"] yes = "true" no = "false" help = "Should the bridge send a read Receipt from the bridge bot when a message has been sent to WhatsApp?" - bind = ":__FINALPATH__/config.yaml" + bind = ":__INSTALL_DIR__/config.yaml" [privacy.config.send_presence_on_typing] ask = "Send Presence on typing?" @@ -132,7 +132,7 @@ services = ["__APP__"] yes = "true" no = "false" help = "Send the Presence as 'available' to WhatsApp when Users start typing on a Portal." - bind = ":__FINALPATH__/config.yaml" + bind = ":__INSTALL_DIR__/config.yaml" [privacy.config.url_previews] ask = "Enable URL Preview?" @@ -140,7 +140,7 @@ services = ["__APP__"] yes = "true" no = "false" help = "Should the Bridge detect URLs in outgoing messages, ask the HomeServer to generate a Preview, and send it to WhatsApp?" - bind = ":__FINALPATH__/config.yaml" + bind = ":__INSTALL_DIR__/config.yaml" [advanced] name = "Advanced Settings" @@ -160,19 +160,19 @@ services = ["__APP__"] ask = "Localpart template of MXIDs for WhatsApp users" type = "string" help = "Defaults to 'whatsapp_{{.}}'. '{{.}}' is replaced with the phone number 'msidsn' of the WhatsApp user." - bind = ":__FINALPATH__/config.yaml" + bind = ":__INSTALL_DIR__/config.yaml" [advanced.whatsapp.os_name] ask = "Device name in the 'WhatsApp Web' section of the smartphone app" type = "string" - bind = ":__FINALPATH__/config.yaml" + bind = ":__INSTALL_DIR__/config.yaml" [advanced.whatsapp.browser_name] ask = "Browser name that determines the logo shown in the smartphone app" type = "select" choices = ["unknown", "chrome", "firefox", "ie", "opera", "safari", "edge", "desktop", "ipad", "android_tablet", "ohana", "aloha", "catalina", "tcl_tv"] help = "Must be 'unknown' for a generic icon or a valid browser name if you want a specific logo." - bind = ":__FINALPATH__/config.yaml" + bind = ":__INSTALL_DIR__/config.yaml" [advanced.appservice] name = "HomeServer Application Service" @@ -183,7 +183,7 @@ services = ["__APP__"] yes = "true" no = "false" help = "Enable only if HomeServer supports https://github.com/matrix-org/matrix-spec-proposals/pull/2246?" - bind = ":__FINALPATH__/config.yaml" + bind = ":__INSTALL_DIR__/config.yaml" [advanced.appservice.ephemeral_events] ask = "Receive Ephemeral Events via AppService transactions?" @@ -191,14 +191,14 @@ services = ["__APP__"] yes = "true" no = "false" help = "Enable only if HomeServer supports MSC2409 (i.e. Synapse 1.22+). If enabled, you should disable bridge -> 'sync_with_custom_puppets'." - bind = ":__FINALPATH__/config.yaml" + bind = ":__INSTALL_DIR__/config.yaml" [advanced.appservice.min_level] ask = "Logging print level for Standard Output" type = "select" choices = ["debug", "info", "warn", "error", "fatal"] help = "Minimum severity for log messages printed to stdout/stderr. This doesn't affect the log file." - bind = ":__FINALPATH__/config.yaml" + bind = ":__INSTALL_DIR__/config.yaml" [advanced.metrics] name = "Prometheus Metrics" @@ -208,12 +208,12 @@ services = ["__APP__"] type = "boolean" yes = "true" no = "false" - bind = "metrics>enabled:__FINALPATH__/config.yaml" + bind = "metrics>enabled:__INSTALL_DIR__/config.yaml" [advanced.metrics.listen_port] ask = "IP and Port for the Metrics listener?" type = "string" help = "Defaults to: '127.0.0.1:8001'. The path is always /metrics" - bind = "metrics>listen:__FINALPATH__/config.yaml" + bind = "metrics>listen:__INSTALL_DIR__/config.yaml" visible = "enable_metrics" diff --git a/doc/ADMIN.md b/doc/ADMIN.md new file mode 100644 index 0000000..a205c7b --- /dev/null +++ b/doc/ADMIN.md @@ -0,0 +1,18 @@ +## Configuration of the bridge + +The bridge is [roughly configured at installation](https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh/blob/master/conf/config.yaml), e.g. allowed admin and user of the bot. +Finer configuration can be done by using the existing config panel in the Yunohost admin panel or by modifying the +following configuration file with SSH: +```/opt/yunohost/mautrix_whatsapp/config.yaml``` +and then restarting the mautrix_whatsapp service. + +#### User permissions + + +#### End-to-bridge encryption +The bridge can optionally encrypt messages between Matrix users and the bridge to hide messages from the homeserver. Using Postgres is strongly recommended when using end-to-bridge encryption. + +If you want to enable it, go to the config panel section `Privacy -> Portal Rooms & Encryption Settings`. If you enable `Allow Encryption between Matrix Client and Bridge Server?`, the bridge won't enable encryption on its own, but will work in encrypted rooms. +Alternatively two more options will appear, `Force-enable Encryption in all Portal Rooms the Bridge creates?` which will automatically enable encryption in new portals and `Require encryption?` which will enforce encryption on any of the messages that you send (this will make the bridge drop any future unencrypted messages). + +There is also the possibity to configure it in the bridge configuration YAML file in the section `bridge: encryption`. \ No newline at end of file diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md new file mode 100644 index 0000000..278bae3 --- /dev/null +++ b/doc/ADMIN_fr.md @@ -0,0 +1,17 @@ +### Configuration de la passerelle + +La passerelle est [configurĂ©e avec les paramĂštres standards adaptĂ©s pour votre YunoHost et l'instance Matrix-Synapse sĂ©lectionnĂ©e](https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh/blob/master/conf/config.yaml). +Une configuration plus fine peut ĂȘtre effectuĂ©e en utilisant le panneau de configuration existant dans le panneau d'administration de Yunohost ou en modifiant le fichier de configuration suivant avec SSH: +``` /opt/yunohost/mautrix_whatsapp/config.yaml``` +puis en redĂ©marrant le service mautrix_whatsapp. + +#### User permissions + + +#### End-to-bridge encryption +Le robot peut Ă©ventuellement chiffrer les messages entre les utilisateurs de Matrix et la passarelle pour cacher les messages du serveur domestique. L'utilisation de Postgres est fortement recommandĂ©e lors de l'utilisation du chiffrement end-to-bridge. + +Si vous voulez l'activer, allez dans la section `Privacy -> Portal Rooms & Encryption Settings` du panneau de configuration. Si vous activez `Allow Encryption between Matrix Client and Bridge Server?`, la passarelle n'activera pas le cryptage d'elle-mĂȘme, mais fonctionnera dans les salles cryptĂ©es. +Sinon, deux autres options apparaissent, `Force-enable Encryption in all Portal Rooms the Bridge creates?` qui activera automatiquement le cryptage dans les nouveaux portails et `Require encryption?` qui imposera le cryptage sur tous les messages que vous envoyez (ce qui fera que le robot abandonnera tous les messages non cryptĂ©s Ă  l'avenir). + +Il est Ă©galement possible de le configurer dans le fichier YAML de configuration du robot dans la section `bridge: encryption`. \ No newline at end of file diff --git a/doc/DEVELOPMENT.md b/doc/DEVELOPMENT.md new file mode 100644 index 0000000..cf74fbd --- /dev/null +++ b/doc/DEVELOPMENT.md @@ -0,0 +1,9 @@ +## 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/DEVELOPMENT_fr.md b/doc/DEVELOPMENT_fr.md new file mode 100644 index 0000000..11bd6c0 --- /dev/null +++ b/doc/DEVELOPMENT_fr.md @@ -0,0 +1,10 @@ +## 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 diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index aed5895..0000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1,103 +0,0 @@ -## List of known public services - -* Ask on one of the following rooms: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net - -## Bridging usage -** Note that several WhatsApp and Matrix users can be bridged, each WhatsApp account has its own bot administration room. If they are in a same WhatsApp group, only one matrix room will be created. ** - -### Bridge a WhatsApp user and a Matrix user -* First your matrix user or server has to be authorized in the bridge configuration (see below) -* Then, invite the bot (default @whatsappbot:yoursynapse.domain) -* The room with the Mautrix-WhatsApp bot is called "administration room". -* Type ``login`` -* Capture the QR code with the camera in the whatsapp of your VM or smartphone (WhatsApp Web) -* Send ``help`` to the bot in the created room to know how to control the bot. -See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/go/whatsapp/authentication.html) - -### Bridge an existing room | Bridge Whatsapp to Signal over Matrix -By default, the bridge creates a portal room for each WA group that the WA user actively uses. -Your can also create a portal for an existing Matrix room. **Note that this can be a room created by another bridge, e.g. a Signal portal room** -1. Invite the bridge bot to the room (with an authorized user) -2. type `!wa create` -3. Your logged in WA user creates a new corresponding group. -4. Get the WA invite link `!wa invite-link` and share it with friends. Or invite Whatsapp puppets to room. -5. Optional: Activate relaybot, see next section. - -### Relaybot: Bridge a group for several Matrix and several WhatsApp users to chat together -**When upgrading from /dev/null | awk '/-----BEGIN CERTIFICATE-----/, /-----END CERTIFICATE-----/' >> /usr/local/share/ca-certificates/synapse.vm.crt -update-ca-certificates -``` - -### Miscellaneous information - - * Matrix room (matrix bridges in YunoHost): #mautrix_yunohost:matrix.fdn.fr - * Matrix room (upstream app): #whatsapp:maunium.net -In case you need to upload your logs somewhere, be aware that they contain your contacts' and your phone numbers. Strip them out with -``| 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 deleted file mode 100644 index 5c4a5ad..0000000 --- a/doc/DISCLAIMER_fr.md +++ /dev/null @@ -1,87 +0,0 @@ -## Liste de passerelles publiques - -* Demandez sur un des salons suivants: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net - -## Usages de la passerelle -** Notez que plusieurs comptes WhatsApp et Matrix peuvent ĂȘtre relayĂ©s, chaque compte WhatsApp connectĂ© a son propre Salon d'Administration. Si plusieurs utilisateur.ice.s du Robot sont dans un mĂȘme groupe WhatsApp, seul un Salon Matrix sera créé par la passerelle. ** - -### Relayer TOUTES les conversations entre UN compte WhatsApp et UN compte Matrix -* PrĂ©requis : votre compte Matrix ou le serveur sur lequel il est hĂ©bergĂ© doit ĂȘtre autorisĂ© dans la configuration de la passerelle (voir ci-dessous) -* Invitez le Robot (par dĂ©faut @whatsappbot:synapse.votredomaine) Ă  une nouvelle conversation. -* Ce nouveau salon d'administration du Robot Mautrix-WhatsApp est appelĂ© "Administration Room". -* Tapez ``login`` -* Scannez le QR-code avec la camĂ©ra Whatsapp de votre Machine Virtuelle ou ordiphone (option WhatsApp Web dans l'appli) -* Envoyez ``help`` au Robot dans le "Administration Room" pour une liste des commandes d'administration de la passerelle. -Voir aussi [upstream wiki Authentication page](https://docs.mau.fi/bridges/go/whatsapp/authentication.html) - -#### Robot-Relai "Relaybot": Relayer les conversations de TOUS les comptes Matrix et TOUS les comptes WhatsApp prĂ©sents dans UN groupe/salon - -* PrĂ©requis : CrĂ©er un nouveau salon vide "Relaybot Administration Room" et rechercher son identifiant. -* Activer l'option Robot-Relai "Relaybot" dans la configuration de la passerelle (default=disabled, voir ci-dessous) et ajouter l'identifiant du salon d'administration du Relaybot "Relaybot Administration Room". -* RedĂ©marrer le service mautrix_whatsapp -* Vous pouvez maintenant relayer un groupe WhatsApp en y invitant le numĂ©ro de tĂ©lĂ©phone du compte WhatsApp connectĂ© au RobotRelai. CĂŽtĂ© WhatsApp, tous les messages venant de Matrix seront vus comme envoyĂ©s depuis le compte WhatsApp connectĂ©, avec un prĂ©fix indiquant le compte Matrix correspondant. CĂŽtĂ© Matrix, la passerelle va crĂ©er des comptes Matrix pour chaque compte WhatsApp prĂ©sent dans le groupe relayĂ©. Les messages sont indiquĂ©s comme provenant soit du numĂ©ro de tĂ©lĂ©phone, soit du pseudo WhatsApp. -Voir aussi [la page wiki principale sur le Robot-Relai](https://docs.mau.fi/bridges/go/whatsapp/relaybot.html) - -### Configuration de la passerelle - -La passerelle est [configurĂ©e avec les paramĂštres standards adaptĂ©s pour votre YunoHost et l'instance Matrix-Synapse sĂ©lectionnĂ©e](https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh/blob/master/conf/config.yaml). Vous pouvez par exemple ajouter des administrateur.ice.s et utilisateur.ice.s du Robot autorisĂ©s en modifiant le fichier de configuration par liaison SSH: -``` sudo nano /opt/yunohost/mautrix_whatsapp/config.yaml``` -puis en redĂ©marrant le service: -``` sudo yunohost service restart mautrix_whatsapp``` - -#### End-to-bridge encryption -Le robot peut Ă©ventuellement chiffrer les messages entre les utilisateurs de Matrix et la passarelle pour cacher les messages du serveur domestique. L'utilisation de Postgres est fortement recommandĂ©e lors de l'utilisation du chiffrement end-to-bridge. - -Si vous voulez l'activer, cherchez l'option ```bridge → encryption``` dans le fichier de configuration. Si vous dĂ©finissez uniquement l'option ``allow: true``, le robot n'activera pas le chiffrement de lui-mĂȘme, mais travaillera dans les portails chiffrĂ©s. Si vous dĂ©finissez ```default: true```, la passerelle activera automatiquement le chiffrement dans les nouveaux portails. -Il y a Ă©galement la possibilitĂ© de dĂ©finir ```require: true``` pour imposer le chiffrement sur tous les messages que vous envoyez (cela interdira tous les messages non chiffrĂ©s). - -### Support multi-comptes - -* Les utilisateur.ice.s du Robot ne sont pas liĂ©s aux comptes Yunohost. N'importe quel compte Matrix ou serveur Synapse autorisĂ©s dans la configuration de la passerelle peut inviter/utiliser le Robot. -* Le robot WhatsApp est un utilisateur Matrix-Synapse local, mais accessible via la fĂ©dĂ©ration (Synapse public ou privĂ©). -* Plusieurs comptes WhatsApp et Matrix peuvent ĂȘtre liĂ©s avec une seule passerelle, chaque compte a son propre salon d'administration. -* Si plusieurs utilisateur.ice.s du Robot sont dans un mĂȘme groupe WhatsApp, seul un Salon Matrix sera créé par la passerelle. Autrement dit, la passerelle construit un seul miroir du rĂ©seau de discussion existant sur WhatsApp (utilisateurs et salons). -* Voir https://github.com/YunoHost-Apps/synapse_ynh#multi-users-support - -### Support multi-instance - -* L'installation multi-instance devrait fonctionner. Plusieurs instances de passerelles pourraient ĂȘtre installĂ©es pour une instance de Matrix-Synapse. Cela permet Ă  un compte matrix de se relier Ă  plusieurs comptes WhatsApp. -* Plusieurs instances de passerelles pourraient ĂȘtre installĂ©es pour que chaque instance de Matrix-Synapse puisse en bĂ©nĂ©ficier. Mais une passerelle peut ĂȘtre utilisĂ©e par les comptes de plusieurs instances Matrix-Synapse. - -### Architectures supportĂ©es - -ARM, ARM64, AMD64 - -### Limitations - -* Les appels Audio/Video ne sont pas relayĂ©s. Seule une notification apparait. -* Si WhatsApp perd la connexion, par ex. l'ordiphone est mis en mode avion ou les notifications poussĂ©es sont dĂ©sactivĂ©es, le robot doit parfois ĂȘtre redĂ©marrĂ© Ă  la main en envoyant un message ``wa !reconnnect`` dans le salon d'administration. - -### Informations additionnelles - -* Il est recommandĂ© d'installer WhatsApp sur une machine Android virtuelle tournant sur un serveur, cf. le [page Android-VM-Setup du wiki](https://docs.mau.fi/bridges/go/whatsapp/android-vm-setup.html) - -Pour tester la communication entre le Service d'Application et Matrix-Synapse sur une Machine Virtuelle (ex. avec un nom de domaine: synapse.vm), vous devez installer un certificat: -``` -echo | openssl s_client -showcerts -servername synapse.vm -connect synapse.vm:443 2>/dev/null | awk '/-----BEGIN CERTIFICATE-----/, /-----END CERTIFICATE-----/' >> /usr/local/share/ca-certificates/synapse.vm.crt -update-ca-certificates -``` - -### Informations diverses - -* Salon Matrix sur les Passerelles dans Yunohost): #mautrix_yunohost:matrix.fdn.fr -* Salon Matrix (application principale): #whatsapp:maunium.net -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 diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md new file mode 100644 index 0000000..29bd0ee --- /dev/null +++ b/doc/POST_INSTALL.md @@ -0,0 +1,37 @@ +## List of known public services + +* Ask on one of the following rooms: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net + +## Bridging usage +** Note that several WhatsApp and Matrix users can be bridged, each WhatsApp account has its own bot administration room. If they are in a same WhatsApp group, only one matrix room will be created. ** + +### Bridge a WhatsApp user and a Matrix user +* First your matrix user or server has to be authorized in the bridge configuration (see below) +* Then, invite the bot (default @whatsappbot:yoursynapse.domain) +* The room with the Mautrix-WhatsApp bot is called "administration room". +* Type ``login`` +* Capture the QR code with the camera in the WhatsApp of your VM or smartphone (WhatsApp Web) +* Send ``help`` to the bot in the created room to know how to control the bot. + See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/go/whatsapp/authentication.html) + +### Bridge an existing room +By default, the bridge creates a portal room for each WhatsApp group that the WhatsApp user actively uses. +Your can also create a portal for an existing Matrix room. **Note that this can be a room created by another bridge, e.g. a Signal portal room** +1. Invite the bridge bot to the room (with an authorized user) +2. Type `!wa create` +3. Your logged in WA user creates a new corresponding group. +4. Get the WA invite link `!wa invite-link` and share it with friends. Or invite WhatsApp puppets to room. +5. Optional: Activate relaybot, see next section. + +### Relaybot: Bridge a group for several Matrix and several WhatsApp users to chat together + +To be able to bridge not only your logged in Matrix account but also Matrix friends you invite to a portal room, you need to: +1. Enable relaybot setting in the config panel section `Main Settings -> Puppetting Bridge Settings` or in the bridge configuration YAML file `relay: enabled: true`. Also make sure that the users you want to invite have at least the `relay` level in the `permissions` section (this can be configured in the config panel section `Main Settings -> Permissions for using the bridge`). +2. Login to your WhatsApp account in the (main) administration room +3. Depending on what has been selected during installation this could be done only by admins, but can also be changed in the config panel section `Main Settings -> Puppetting Bridge Settings` or in the bridge configuration YAML file `relay: admin_only`. +4. Write `!wa set-relay` in each of the rooms you want to relay to (re-)activate the relaybot function. + + +* In WhatsApp: all messages will be seen as received from the account who is logged in with a prefix for the source matrix user. +* On the matrix side: the bridge will create matrix puppets corresponding to the WhatsApp users when they send a message. + See also [upstream wiki Relaybot page](https://docs.mau.fi/bridges/general/relay-mode.html) \ No newline at end of file diff --git a/doc/POST_INSTALL_fr.md b/doc/POST_INSTALL_fr.md new file mode 100644 index 0000000..92a1ccc --- /dev/null +++ b/doc/POST_INSTALL_fr.md @@ -0,0 +1,24 @@ +## Liste de passerelles publiques + +* Demandez sur un des salons suivants: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net + +## Usages de la passerelle +** Notez que plusieurs comptes WhatsApp et Matrix peuvent ĂȘtre relayĂ©s, chaque compte WhatsApp connectĂ© a son propre Salon d'Administration. Si plusieurs utilisateur.ice.s du Robot sont dans un mĂȘme groupe WhatsApp, seul un Salon Matrix sera créé par la passerelle. ** + +### Relayer TOUTES les conversations entre UN compte WhatsApp et UN compte Matrix +* PrĂ©requis : votre compte Matrix ou le serveur sur lequel il est hĂ©bergĂ© doit ĂȘtre autorisĂ© dans la configuration de la passerelle (voir ci-dessous) +* Invitez le Robot (par dĂ©faut @whatsappbot:synapse.votredomaine) Ă  une nouvelle conversation. +* Ce nouveau salon d'administration du Robot Mautrix-WhatsApp est appelĂ© "Administration Room". +* Tapez ``login`` +* Scannez le QR-code avec la camĂ©ra Whatsapp de votre Machine Virtuelle ou ordiphone (option WhatsApp Web dans l'appli) +* Envoyez ``help`` au Robot dans le "Administration Room" pour une liste des commandes d'administration de la passerelle. + Voir aussi [upstream wiki Authentication page](https://docs.mau.fi/bridges/go/whatsapp/authentication.html) + +### Robot-Relai "Relaybot": Relayer les conversations de TOUS les comptes Matrix et TOUS les comptes WhatsApp prĂ©sents dans UN groupe/salon + +1. Activer l'option `Should Relay Mode be allowed?` dans le panneau de configuration (section `Main Settings -> Puppetting Bridge Settings`) ou dans le fichier YAML de configuration du robot `relay: enabled: true`. Assurez-vous Ă©galement que les utilisateurs que vous voulez inviter ont au moins le niveau `relay` dans la section `permissions` (ceci peut ĂȘtre configurĂ© dans la section `Main Settings -> Permissions for using the bridge` du panneau de configuration). +2. En fonction de ce qui a Ă©tĂ© sĂ©lectionnĂ© lors de l'installation, cela peut ĂȘtre fait uniquement par les administrateurs, mais peut Ă©galement ĂȘtre modifiĂ© dans la section `Main Settings -> Puppetting Bridge Settings` du panneau de configuration ou dans le fichier YAML de configuration du robot `relay: admin_only` +3. Ecrivez `!wa set-relay` dans chacune des piĂšces que vous voulez relayer pour (rĂ©)activer la fonction de relaybot. + +* Vous pouvez maintenant relayer un groupe WhatsApp en y invitant le numĂ©ro de tĂ©lĂ©phone du compte WhatsApp connectĂ© au RobotRelai. CĂŽtĂ© WhatsApp, tous les messages venant de Matrix seront vus comme envoyĂ©s depuis le compte WhatsApp connectĂ©, avec un prĂ©fix indiquant le compte Matrix correspondant. CĂŽtĂ© Matrix, la passerelle va crĂ©er des comptes Matrix pour chaque compte WhatsApp prĂ©sent dans le groupe relayĂ©. Les messages sont indiquĂ©s comme provenant soit du numĂ©ro de tĂ©lĂ©phone, soit du pseudo WhatsApp. + Voir aussi [la page wiki principale sur le Robot-Relai](https://docs.mau.fi/bridges/go/whatsapp/relaybot.html) \ No newline at end of file diff --git a/doc/PRE_INSTALL.md b/doc/PRE_INSTALL.md new file mode 100644 index 0000000..5d48c4e --- /dev/null +++ b/doc/PRE_INSTALL.md @@ -0,0 +1,33 @@ +## Multi-user support + +* Bot users are not related to Yunohost users. Any Matrix account or Synapse server autorized in the configuration of the bridge can invite/use the bot. +* The WhatsApp bot is a local Matrix-Synapse user, but accessible through federation (synapse public or private). +* Several WhatsApp and Matrix users can be bridged with one bridge, each user has its own bot administration room. +* If several bot users are in a same WhatsApp group, only one Matrix room will be created by the bridge. +* See https://github.com/YunoHost-Apps/synapse_ynh#multi-users-support + +## Limitations + +* Audio/Video calls are not bridged yet. +* If WhatsApp loses connection, e.g. the phone is set in flight mode or push notifications are deactivated, the bot has sometimes to be restarted manually by sending a reconnnect message in the matrix administration room. +* WhatsApp needs to get presence from the official app every two weeks at least, so bridge will send a reminder in the administration room. + +## Additional information + +* It is recommended to install WhatsApp on a virtual android running on a server, see [upstream wiki Android-VM-Setup page](https://docs.mau.fi/bridges/go/whatsapp/android-vm-setup.html) +**More information on the documentation page:** + https://docs.mau.fi/bridges/go/whatsapp/index.html + +To test communication between the App Service and Matrix-Synapse on a VM (e.g. with domain name: synapse.vm), you must install a certificate: +``` +echo | openssl s_client -showcerts -servername synapse.vm -connect synapse.vm:443 2>/dev/null | awk '/-----BEGIN CERTIFICATE-----/, /-----END CERTIFICATE-----/' >> /usr/local/share/ca-certificates/synapse.vm.crt +update-ca-certificates +``` + +## Miscellaneous information + +* Matrix room (matrix bridges in YunoHost): #mautrix_yunohost:matrix.fdn.fr +* Matrix room (upstream app): #whatsapp:maunium.net + In case you need to upload your logs somewhere, be aware that they contain your contacts' and your phone numbers. Strip them out with + ``| 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. \ No newline at end of file diff --git a/doc/PRE_INSTALL_fr.md b/doc/PRE_INSTALL_fr.md new file mode 100644 index 0000000..7ee8375 --- /dev/null +++ b/doc/PRE_INSTALL_fr.md @@ -0,0 +1,31 @@ +## Support multi-comptes + +* Les utilisateur.ice.s du Robot ne sont pas liĂ©s aux comptes Yunohost. N'importe quel compte Matrix ou serveur Synapse autorisĂ©s dans la configuration de la passerelle peut inviter/utiliser le Robot. +* Le robot WhatsApp est un utilisateur Matrix-Synapse local, mais accessible via la fĂ©dĂ©ration (Synapse public ou privĂ©). +* Plusieurs comptes WhatsApp et Matrix peuvent ĂȘtre liĂ©s avec une seule passerelle, chaque compte a son propre salon d'administration. +* Si plusieurs utilisateur.ice.s du Robot sont dans un mĂȘme groupe WhatsApp, seul un Salon Matrix sera créé par la passerelle. Autrement dit, la passerelle construit un seul miroir du rĂ©seau de discussion existant sur WhatsApp (utilisateurs et salons). +* Voir https://github.com/YunoHost-Apps/synapse_ynh#multi-users-support + +## Limitations + +* Les appels Audio/Video ne sont pas relayĂ©s. Seule une notification apparait. +* Si WhatsApp perd la connexion, par ex. l'ordiphone est mis en mode avion ou les notifications poussĂ©es sont dĂ©sactivĂ©es, le robot doit parfois ĂȘtre redĂ©marrĂ© Ă  la main en envoyant un message ``wa !reconnnect`` dans le salon d'administration. +* WhatsApp doit obtenir la prĂ©sence de l'application officielle toutes les deux semaines au moins, c'est pourquoi le robot enverra un rappel dans la salle d'administration. + +## Informations additionnelles + +* Il est recommandĂ© d'installer WhatsApp sur une machine Android virtuelle tournant sur un serveur, cf. le [page Android-VM-Setup du wiki](https://docs.mau.fi/bridges/go/whatsapp/android-vm-setup.html) + +Pour tester la communication entre le Service d'Application et Matrix-Synapse sur une Machine Virtuelle (ex. avec un nom de domaine: synapse.vm), vous devez installer un certificat: +``` +echo | openssl s_client -showcerts -servername synapse.vm -connect synapse.vm:443 2>/dev/null | awk '/-----BEGIN CERTIFICATE-----/, /-----END CERTIFICATE-----/' >> /usr/local/share/ca-certificates/synapse.vm.crt +update-ca-certificates +``` + +## Informations diverses + +* Salon Matrix sur les Passerelles dans Yunohost): #mautrix_yunohost:matrix.fdn.fr +* Salon Matrix (application principale): #whatsapp:maunium.net + 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). \ No newline at end of file diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 4402fa1..0000000 --- a/manifest.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "name": "Matrix-WhatsApp bridge", - "id": "mautrix_whatsapp", - "packaging_format": 1, - "description": { - "en": "Matrix / Synapse puppeting bridge for WhatsApp", - "fr": "Passerelle Matrix / Synapse pour WhatsApp" - }, - "version": "0.9.0~ynh1", - "url": "https://github.com/mautrix/whatsapp", - "upstream": { - "license": "AGPL-3.0-or-later", - "website": "https://maunium.net/go/mautrix-whatsapp/", - "admindoc": "https://docs.mau.fi/bridges/go/whatsapp/index.html", - "code": "https://github.com/mautrix/whatsapp" - }, - "license": "AGPL-3.0-or-later", - "maintainer": { - "name": "thardev", - "email": "", - "url": "https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh" - }, - "requirements": { - "yunohost": ">= 4.3.0" - }, - "multi_instance": true, - "services": [ - "postgresql" - ], - "arguments": { - "install": [ - { - "name": "synapsenumber", - "type": "string", - "ask": { - "en": "Choose the local Synapse instance number to communicate with mautrix_whatsapp.", - "fr": "Choisissez le numĂ©ro de l'instance Synapse qui doit communiquer avec mautrix_whatsapp." - }, - "example": "2 (for instance synapse__2)", - "help": { - "en": "If you installed Synapse only once time, then leave default value 1.", - "fr": "Si vous n'avez installĂ© qu'une fois Synapse, gardez la valeur par dĂ©faut 1." - }, - "default": "1" - }, - { - "name": "botname", - "type": "string", - "ask": { - "en": "Choose a local Synapse user name for the WhatsApp bot", - "fr": "Choisissez un nom d'utilisateur Synapse local pour le robot WhatsApp" - }, - "example": "whatsappbot", - "help": { - "en": "A system user will be created. Invite @whatsappbot:localsynapse.servername from an authorized Matrix account to start bridging.\nGive the Matrix server_name, not the full domain/URL.", - "fr": "Un utilisateur systĂšme sera créé. Inviter @whatsappbot:localsynapse.servername depuis un compte Matrix autorisĂ© pour dĂ©marrer une passerelle.\nDonner le nom du serveur Matrix, pas le domaine/URL complet." - }, - "default": "whatsappbot" - }, - { - "name": "bot_synapse_adm", - "type": "boolean", - "ask": { - "en": "Give the WhatsApp bot administrator rights to the Synapse instance?", - "fr": "Donner au robot WhatsApp des droits administrateur Ă  l'instance Synapse ?" - }, - "help": { - "en": "If true, the bot can group WhatsApp chats in a Matrix space.\nNot required if you set up Synapse so that non-admins are authorized to create communities.", - "fr": "Si true, le robot groupera les conversations WhatsApp dans une communautĂ© Matrix.\nPas nĂ©cessaire si vous avez rĂ©glĂ© Synapse pour qu'il autorise les non-admin Ă  crĂ©er des communautĂ©s." - }, - "default": true - }, - { - "name": "encryption", - "type": "boolean", - "ask": { - "en": "Enable end-to-bridge encryption?", - "fr": "Activer le chiffrement entre Synapse et le bridge ?" - }, - "help": { - "en": "Only activate if you know the prerequisites and constraints related to e2b.", - "fr": "N'activer que si vous connaissez les prĂ©requis et constraintes liĂ©es Ă  e2b." - }, - "default": false - }, - { - "name": "botadmin", - "type": "string", - "ask": { - "en": "Choose the Matrix account administrator of the WhatsApp bot", - "fr": "Choisissez le compte Matrix administrateur du robot WhatsApp" - }, - "example": "@johndoe:localsynapse.servername or @johndoe:matrix.org", - "help": { - "en": "The administrator does not need to be a local Synapse account. Valid formats are @johndoe:localsynapse.servername or @johndoe:matrix.org", - "fr": "L'administrateur peut ne pas ĂȘtre un compte local Synapse. Les formats valables sont @johndoe:localsynapse.servername or @johndoe:matrix.org" - } - }, - { - "name": "botusers", - "type": "string", - "ask": { - "en": "Choose Matrix user(s) authorized to bridge with the WhatsApp bot.", - "fr": "Choisissez le/les compte(s) Matrix autorisĂ©s Ă  utiliser la passerelle WhatsApp." - }, - "example": "@johndoe:server.name or server.name or *", - "help": { - "en": "A remote or local user (@johndoe:server.name),the local server (server.name), a remote server (matrix.org), or all remote/local servers (*) can be authorized.\nGive the Matrix server_name, not the full domain/URL.\nIt is also possible to specify multiple values by separating them with comma. Example: @johndoe:server.name,domain.tld,matrix.org", - "fr": "Un compte local ou distant (@johndoe:server.name), le serveur local (server.name), un serveur distant (matrix.org), ou tous les serveurs remote/local (*).\nDonner le nom du serveur Matrix, pas le domaine/URL complet\nIl est Ă©galement possible de spĂ©cifier plusieurs valeurs en les sĂ©parant par une virgule. Exemple : @johndoe:server.name,domain.tld,matrix.org" - } - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..471c9b8 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,115 @@ +packaging_format = 2 +id = "mautrix_whatsapp" +name = "Matrix-WhatsApp bridge" +description.en = "Matrix / Synapse puppeting bridge for WhatsApp" +description.fr = "Passerelle Matrix / Synapse pour WhatsApp" +version = "0.9.0~ynh1" +maintainers = ["thardev"] + +[upstream] +license = "AGPL-3.0-or-later" +website = "https://maunium.net/go/mautrix-whatsapp/" +code = "https://github.com/mautrix/whatsapp" +admindoc = "https://docs.mau.fi/bridges/go/whatsapp/index.html" + +[integration] +yunohost = ">= 11.1" +architectures = ["amd64", "arm64", "armhf"] +multi_instance = true +ldap = false +sso = false +disk = "100M" +ram.build = "256M" +ram.runtime = "1024M" + +[install] + +[install.synapse_instance] +ask.en = "Choose the local Synapse instance to communicate with mautrix_whatsapp." +ask.fr = "Choisissez l'instance Synapse qui doit communiquer avec mautrix_whatsapp." +type = "app" +pattern.regexp = "synapse(__)*[0-9]*" +pattern.error = "Invalid app selected. Please select a Synapse instance." +help.en = "Usually the Synapse instances contain a number after it is installed more than one time. E.g. synapse__1 will be the second instance." +help.fr = "En gĂ©nĂ©ral, les instances de Synapse contiennent un numĂ©ro aprĂšs avoir Ă©tĂ© installĂ©es plus d'une fois. Par exemple, synapse__1 sera la deuxiĂšme instance." +default = "synapse" + +[install.botname] +ask.en = "Choose a local Synapse user name for the WhatsApp bot" +ask.fr = "Choisissez un nom d'utilisateur Synapse local pour le robot WhatsApp" +type = "string" +example = "whatsappbot" +help.en = "A system user will be created. Invite @whatsappbot:localsynapse.servername from an authorized Matrix account to start bridging.Give the Matrix server_name, not the full domain/URL." +help.fr = "Un utilisateur systĂšme sera créé. Inviter @whatsappbot:localsynapse.servername depuis un compte Matrix autorisĂ© pour dĂ©marrer une passerelle.Donner le nom du serveur Matrix, pas le domaine/URL complet." +default = "whatsappbot" + +[install.bot_synapse_adm] +ask.en = "Give the WhatsApp bot administrator rights to the Synapse instance?" +ask.fr = "Donner au robot WhatsApp des droits administrateur Ă  l'instance Synapse ?" +type = "boolean" +help.en = "If true, the bot can group WhatsApp chats in a Matrix space.Not required if you set up Synapse so that non-admins are authorized to create communities." +help.fr = "Si true, le robot groupera les conversations WhatsApp 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 + +[install.encryption] +ask.en = "Enable end-to-bridge encryption?" +ask.fr = "Activer le chiffrement entre Synapse et le bridge ?" +type = "boolean" +help.en = "Only activate if you know the prerequisites and constraints related to E2B." +help.fr = "N'activer que si vous connaissez les prĂ©requis et constraintes liĂ©es Ă  E2B." +default = true + +[install.botadmin] +ask.en = "Choose the Matrix account administrator of the WhatsApp bot" +ask.fr = "Choisissez le compte Matrix administrateur du robot WhatsApp" +type = "string" +example = "@johndoe:localsynapse.servername or @johndoe:matrix.org" +help.en = "The administrator does not need to be a local Synapse account. Valid formats are @johndoe:localsynapse.servername or @johndoe:matrix.org" +help.fr = "L'administrateur peut ne pas ĂȘtre un compte local Synapse. Les formats valables sont @johndoe:localsynapse.servername or @johndoe:matrix.org" + +[install.botusers] +ask.en = "Choose Matrix user(s) authorized to bridge with the WhatsApp bot." +ask.fr = "Choisissez le/les compte(s) Matrix autorisĂ©s Ă  utiliser la passerelle WhatsApp." +type = "string" +example = "@johndoe:server.name or server.name or *" +help.en = """ +A remote or local user (@johndoe:server.name),the local server (server.name), a remote server (matrix.org), or all remote/local servers (*) can be authorized. +Give the Matrix server_name, not the full domain/URL. +It is also possible to specify multiple values by separating them with comma. Example: @johndoe:server.name,domain.tld,matrix.org""" +help.fr = """Un compte local ou distant (@johndoe:server.name), le serveur local (server.name), un serveur distant (matrix.org), ou tous les serveurs remote/local (*). +Donner le nom du serveur Matrix, pas le domaine/URL complet. +Il est Ă©galement possible de spĂ©cifier plusieurs valeurs en les sĂ©parant par une virgule. Exemple : @johndoe:server.name,domain.tld,matrix.org""" + +[resources] + +[resources.apt] +packages = "g++, postgresql, ffmpeg" + +[resources.database] +type = "postgresql" + +[resources.permissions] +main.allowed = "all_users" +main.auth_header = false + +[resources.system_user] +home = "/opt/yunohost/__APP__" + +[resources.install_dir] +dir = "/opt/yunohost/__APP__" + +[resources.ports] +main.default = 8449 + +[resources.sources] + +[resources.sources.main] +in_subdir = false +extract = false +rename = "mautrix-whatsapp" +amd64.url = "https://github.com/mautrix/whatsapp/releases/download/v0.9.0/mautrix-whatsapp-amd64" +amd64.sha256 = "27b5d3ee0cada177207b662072b42923956e38a9c10c4e167eeca17881f3bffb" +arm64.url = "https://github.com/mautrix/whatsapp/releases/download/v0.9.0/mautrix-whatsapp-arm64" +arm64.sha256 = "dc475a2af45988d6d428af18c5f2a30da24930201e0e667a0b749a198a3bd02d" +armhf.url = "https://github.com/mautrix/whatsapp/releases/download/v0.9.0/mautrix-whatsapp-arm" +armhf.sha256 = "22c28d17ec868c4579e8ed64e092b0947a268c82ed9714d3ae45ace05b477fd8" \ No newline at end of file diff --git a/scripts/_common.sh b/scripts/_common.sh index 1431a9f..bc0deff 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,12 +1,5 @@ #!/bin/bash -#================================================= -# COMMON VARIABLES -#================================================= - -# dependencies used by the app (must be on a single line) -pkg_dependencies="g++ postgresql ffmpeg" - #================================================= # CONFIG PANEL SETTERS #================================================= @@ -22,24 +15,24 @@ apply_permissions() { then #ynh_systemd_action --service_name="$app" --action=stop # Get all entries between "permissions:" and "relay:" keys, remove the role part, remove commented parts, format it with newlines and clean whitespaces and double quotes. - allDefinedEntries=$(awk '/permissions:/{flag=1; next} /relay:/{flag=0} flag' "$final_path/config.yaml" | sed "/: $role/d" | sed -r 's/: (admin|user|relay)//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr ',' '\n' ) + allDefinedEntries=$(awk '/permissions:/{flag=1; next} /relay:/{flag=0} flag' "$install_dir/config.yaml" | sed "/: $role/d" | sed -r 's/: (admin|user|relay)//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr ',' '\n' ) # Delete everything from the corresponding role to insert the new defined values. This way we also handle deletion of users. - sed -i "/permissions:/,/relay:/{/: $role/d;}" "$final_path/config.yaml" + sed -i "/permissions:/,/relay:/{/: $role/d;}" "$install_dir/config.yaml" # Ensure that entries with value surrounded with quotes are deleted too. E.g. "users". - sed -i "/permissions:/,/relay:/{/: \"$role\"/d;}" "$final_path/config.yaml" + sed -i "/permissions:/,/relay:/{/: \"$role\"/d;}" "$install_dir/config.yaml" for user in "${usersArray[@]}" do if grep -q -x "${user}" <<< "$allDefinedEntries" then ynh_print_info "User $user already defined in another role." else - sed -i "/permissions:/a \ \\\"$user\": $role" "$final_path/config.yaml" # Whitespaces are needed so that the file can be correctly parsed + sed -i "/permissions:/a \ \\\"$user\": $role" "$install_dir/config.yaml" # Whitespaces are needed so that the file can be correctly parsed fi done fi set +o noglob - ynh_print_info "Users with role $role added in $final_path/config.yaml" + ynh_print_info "Users with role $role added in $install_dir/config.yaml" } @@ -48,19 +41,19 @@ set__listuser() { role="user" ynh_app_setting_set --app=$app --key=listuser --value="$listuser" apply_permissions - ynh_store_file_checksum --file="$final_path/config.yaml" + ynh_store_file_checksum --file="$install_dir/config.yaml" } set__listrelay() { role="relay" ynh_app_setting_set --app=$app --key=listrelay --value="$listrelay" apply_permissions - ynh_store_file_checksum --file="$final_path/config.yaml" + ynh_store_file_checksum --file="$install_dir/config.yaml" } set__listadmin() { role="admin" ynh_app_setting_set --app=$app --key=listadmin --value="$listadmin" apply_permissions - ynh_store_file_checksum --file="$final_path/config.yaml" + ynh_store_file_checksum --file="$install_dir/config.yaml" } \ No newline at end of file diff --git a/scripts/backup b/scripts/backup index 917677c..251bb1b 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,26 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -39,7 +19,7 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # SPECIFIC BACKUP diff --git a/scripts/config b/scripts/config index b1a5de1..364874c 100644 --- a/scripts/config +++ b/scripts/config @@ -3,8 +3,6 @@ source _common.sh source /usr/share/yunohost/helpers ynh_abort_if_errors -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - #================================================= # SPECIFIC GETTERS FOR TOML SHORT KEY #================================================= @@ -15,7 +13,7 @@ get__botname() { } get__listuser() { - existingUsers=$(grep -- "\".*: user" "$final_path/config.yaml" | sed -r 's/: user//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr '\n' ',') + existingUsers=$(grep -- "\".*: user" "$install_dir/config.yaml" | sed -r 's/: user//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr '\n' ',') cat <