diff --git a/README.md b/README.md index 6df8a34..24c4d28 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # A Matrix-WhatsApp puppeting bridge for YunoHost -[![How components fit togeter](https://camo.githubusercontent.com/857d5c90de07312a60e02ce89efe7f8ece86ab6b/68747470733a2f2f67617a697a6f76612e6e65742f7075622f6d6175747269782d77686174736170702e706e67)](https://github.com/tulir/mautrix-whatsapp/wiki) +[![How components fit togeter](https://camo.githubusercontent.com/857d5c90de07312a60e02ce89efe7f8ece86ab6b/68747470733a2f2f67617a697a6f76612e6e65742f7075622f6d6175747269782d77686174736170702e706e67)](https://docs.mau.fi/bridges/go/whatsapp/index.html) [![Integration level](https://dash.yunohost.org/integration/mautrix_whatsapp.svg)](https://dash.yunohost.org/appci/app/mautrix_whatsapp) -[![Install Mautrix-WhatsApp with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mautrix_whatsapp) +[![Install Mautrix-WhatsApp with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=mautrix_whatsapp) *[Lire ce readme en français.](./README_fr.md)* @@ -10,85 +10,95 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* ## Overview -A puppeting bridge between Matrix and WhatsApp packaged as a YunoHost service. Messages, media and notifications are bridged between a whatsapp user and a matrix user. The matrix user can invite other matrix user in a bridged whatsapp room, such that even people without a whatsapp account can participate to whatsapp group conversations. The ["mautrix-whatsapp"](https://github.com/tulir/mautrix-whatsapp/wiki) bridge consists in a synapse app service and relies on postgresql (mysql also available). Therefore, [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) should be installed beforehand. +A puppeting bridge between Matrix and WhatsApp packaged as a YunoHost service. Messages, media and notifications are bridged between a WhatsApp user and a matrix user. With the RelayBot login option, the matrix user can invite other matrix user in a bridged WhatsApp room, such that even people without a WhatsApp account can participate to WhatsApp group conversations. The ["Mautrix-WhatsApp"](https://docs.mau.fi/bridges/go/whatsapp/index.html) bridge consists in a synapse app service and relies on postgresql (mysql also available). Therefore, [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) should be installed beforehand. -**Shipped version:** 0.1.5 +** Attention: always backup and restore the Yunohost matrix_synapse et mautrix_whatsapp apps together!** + +**Shipped version:** 0.1.6 ## Screenshots ![](Link to an screenshot for this app) -## Demo +## List of known public services -* Contact mautrix_whatsapp@sans-nuage.fr. +* 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) in this new matrix-whatsapp bot administration room. +* 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://github.com/tulir/mautrix-whatsapp/wiki/Authentication) +See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/go/whatsapp/authentication.html) -** 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 group in Matrix "Relaybot" + +### Relaybot: Bridge a group for several Matrix and several WhatsApp users to chat together * First Relaybot option should be enabled in the bridge configuration (default=disabled, see below) and room ID of the relaybot administration room added. * Once the bot administration room is setup, you can also bridge all messages between a Matrix room and a WhatsApp room/group. -In whatsapp all messages will be sent by the account who is logged in with a prefix for the source matrix user. On the matrix side the bridge will still create matrix users corresponding to the whatsapp users when they send a message. -See also [upstream wiki Relaybot page](https://github.com/tulir/mautrix-whatsapp/wiki/Relaybot) +In WhatsApp all messages will be sent by the account who is logged in with a prefix for the source matrix user. On the matrix side the bridge will still create matrix users corresponding to the WhatsApp users when they send a message. +See also [upstream wiki Relaybot page](https://docs.mau.fi/bridges/go/whatsapp/relaybot.html) ## Configuration of the bridge -The bridge is roughly configured at installation, e.g. allowed admin and user of the bot. Finer configuration can be done by modifying the +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 modifying the following configuration file with SSH: ```/opt/yunohost/mautrix_whatsapp/config.yaml``` and then restarting the mautrix_whatsapp service. ## Documentation - * Official "mautrix-whatsapp" documentation: https://github.com/tulir/mautrix-whatsapp/wiki + * Official "Mautrix-WhatsApp" documentation: https://docs.mau.fi/bridges/go/whatsapp/index.html * 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. + * "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. * YunoHost documentation: If more specific documentation is needed, feel free to contribute. ## YunoHost specific features #### Multi-users support -* Bot users are not related to Yunohost users. Any matrix account or server autorized in the configuration of the bridge can 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. +* 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 Signal 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 -Multi-instance installation should work, but was not tested yet. A priori it makes only sense if several synapse instances are installed. +#### Multi-instance support + +* Multi-instance installation should work. Several bridge instances could be installed for one Matrix-Synapse instance so that one Matrix user can bridge several WhatsApp accounts. +* Several bridge instances could be installed for each Matrix-Synapse instance to benefit from it. But one bridge can be used by users from several Matrix-Synapse instances. #### Supported architectures * Tested on ARMv7 in April 2020 -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mautrix_whatsapp%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mautrix_whatsapp/) +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mautrix_whatsapp%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mautrix_whatsapp/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mautrix_whatsapp%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mautrix_whatsapp/) ## 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. +* 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. ## Additional information -* It is recommended to install whatsapp on a virtual android running on a server, see [upstream wiki Android-VM-Setup page](https://github.com/tulir/mautrix-whatsapp/wiki/Android-VM-Setup) +* 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://github.com/tulir/mautrix-whatsapp/wiki +https://docs.mau.fi/bridges/go/whatsapp/index.html ## Links * Report a bug: https://github.com/YunoHost-Apps/mautrix-whatsapp_ynh/issues * App website: https://github.com/YunoHost-Apps/mautrix-whatsapp_ynh + * Upstream app documentation: https://docs.mau.fi/bridges/go/whatsapp/index.html * Upstream app repository: https://github.com/tulir/mautrix-whatsapp * Up-Upstream repository: https://github.com/Rhymen/go-whatsapp * Up-Up-Upstream repository: https://github.com/sigalor/whatsapp-web-reveng @@ -96,8 +106,7 @@ https://github.com/tulir/mautrix-whatsapp/wiki --- -Developers info ----------------- +## Developer info Please do your pull request to the testing branch. To try the testing branch, please proceed like that: @@ -107,7 +116,7 @@ or sudo yunohost app upgrade synapse -u https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh/tree/testing --debug ``` -To test communication between the app service and synapse on a VM, you must install a certificate (as root): +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 diff --git a/README_fr.md b/README_fr.md index b4c18da..ace9381 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,64 +1,108 @@ -# App exemple pour YunoHost - -[![Integration level](https://dash.yunohost.org/integration/REPLACEBYYOURAPP.svg)](https://dash.yunohost.org/appci/app/REPLACEBYYOURAPP) -[![Install REPLACEBYYOURAPP with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=REPLACEBYYOURAPP) +# Une passerelle entre Matrix et WhatsApp pour YunoHost +[![How components fit togeter](https://camo.githubusercontent.com/857d5c90de07312a60e02ce89efe7f8ece86ab6b/68747470733a2f2f67617a697a6f76612e6e65742f7075622f6d6175747269782d77686174736170702e706e67)](https://docs.mau.fi/bridges/go/whatsapp/index.html) +[![Integration level](https://dash.yunohost.org/integration/mautrix-whatsapp.svg)](https://dash.yunohost.org/appci/app/mautrix-whatsapp) +[![Install mautrix-whatsapp with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=mautrix-whatsapp) *[Read this readme in english.](./README.md)* -> *Ce package vous permet d'installer REPLACEBYYOURAPP rapidement et simplement sur un serveur Yunohost. +> *Ce package vous permet d'installer mautrix-whatsapp rapidement et simplement sur un serveur Yunohost. Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* ## Vue d'ensemble -Description rapide de cette application. +Une passerelle entre Matrix et WhatsApp empaquetĂ©e comme un service YunoHost. Les messages, mĂ©dias et notifications sont relayĂ©es entre un compte WhatsApp et un compte Matrix. Avec l'option de connexion Robot-Relai, 1 compte Matrix peut inviter d'autres comptes Matrix dans un salon Matrix relayĂ© avec un groupe WhatsApp, ainsi mĂȘme des personnes sans compte WhatsApp peuvent communiquer avec des utilisateur.ice.s de WhatsApp. La passerelle ["Mautrix-WhatsApp"](https://docs.mau.fi/bridges/go/whatsapp/index.html) consiste en un Service d'Application Matrix-Synapse et repose sur une base-de-donnĂ©es postgresql (mysql Ă©galement possible). C'est pourquoi [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) doit ĂȘtre prĂ©alablemnet installĂ©. -**Version incluse:** 1.0 +** Attention : sauvegardez et restaurez toujours les deux applications Yunohost matrix_synapse et mautrix_whatsapp en mĂȘme temps!** + +**Version incluse:** 0.1.6 ## Captures d'Ă©cran ![](Lien vers une capture d'Ă©cran pour cette application) -## DĂ©mo +## Liste de passerelles publiques -* [DĂ©mo officielle](Lien vers un site de dĂ©monstration pour cette application) +* Demandez sur un des salons suivants: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net -## Configuration +## 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. ** -Comment configurer cette application: via le panneau d'administration, un fichier brut en SSH ou tout autre moyen. +### 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``` ## Documentation - * Documentation officielle: Lien vers la documentation officielle de cette application + * Documentation officielle "Mautrix-WhatsApp": https://docs.mau.fi/bridges/go/whatsapp/index.html + * 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). * Documentation YunoHost: Si une documentation spĂ©cifique est nĂ©cessaire, n'hĂ©sitez pas Ă  contribuer. ## CaractĂ©ristiques spĂ©cifiques YunoHost -#### Support multi-utilisateurs +#### 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 -L'authentification LDAP et HTTP est-elle prise en charge? -L'application peut-elle ĂȘtre utilisĂ©e par plusieurs utilisateurs? +#### 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 -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/REPLACEBYYOURAPP%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/REPLACEBYYOURAPP/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/REPLACEBYYOURAPP%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/REPLACEBYYOURAPP/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/REPLACEBYYOURAPP%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/REPLACEBYYOURAPP/) +* TestĂ© sur ARMv7 en Avril 2020 +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mautrix_whatsapp%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mautrix_whatsapp/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mautrix_whatsapp%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mautrix_whatsapp/) ## Limitations -* Limitations connues. +* 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 -* Autres informations Ă  ajouter sur cette application +* 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) -**Plus d'informations sur la page de documentation:** -https://yunohost.org/packaging_apps +**Plus d'informations sur la page de documentation:** + +* https://docs.mau.fi/bridges/go/whatsapp/index.html +* https://yunohost.org/packaging_apps ## Liens - * Signaler un bug: https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/issues - * Site de l'application: Lien vers le site officiel de cette application - * DĂ©pĂŽt de l'application principale: Lien vers le dĂ©pĂŽt officiel de l'application principale + * Signaler un bug: https://github.com/YunoHost-Apps/mautrix-whatsapp_ynh/issues + * Site de l'application: https://github.com/YunoHost-Apps/mautrix-whatsapp_ynh + * Documentation de l'application principale: https://docs.mau.fi/bridges/go/whatsapp/index.html + * DĂ©pĂŽt de l'application principale: https://github.com/tulir/mautrix-whatsapp + * Up-Upstream repository: https://github.com/Rhymen/go-whatsapp + * Up-Up-Upstream repository: https://github.com/sigalor/whatsapp-web-reveng * Site web YunoHost: https://yunohost.org/ --- @@ -67,11 +111,17 @@ Informations pour les dĂ©veloppeurs ---------------- **Seulement si vous voulez utiliser une branche de test pour le codage, au lieu de fusionner directement dans la banche principale.** -Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing). +Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/mautrix-whatsapp_ynh/tree/testing). Pour essayer la branche testing, procĂ©dez comme suit. ``` -sudo yunohost app install https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing --debug +sudo yunohost app install https://github.com/YunoHost-Apps/mautrix-whatsapp_ynh/tree/testing --debug ou -sudo yunohost app upgrade REPLACEBYYOURAPP -u https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing --debug +sudo yunohost app upgrade mautrix-whatsapp -u https://github.com/YunoHost-Apps/mautrix-whatsapp_ynh/tree/testing --debug +``` + +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 ``` diff --git a/check_process b/check_process index 0fdec9b..26aa5f0 100644 --- a/check_process +++ b/check_process @@ -26,7 +26,7 @@ port="8449" (PORT) synapsenumber="1" whatsappbot="whatsappbot" - bot_is_synapse_admin="Yes" + bot_is_synapse_admin="yes" botadmin="@johndoe:synapsedomain.tld" (USER) botusers="@johndoe:synapsedomain.tld" ; Checks diff --git a/conf/app.src b/conf/app.src index afeb50e..da2c772 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ - SOURCE_URL=https://github.com/tulir/mautrix-whatsapp/archive/v0.1.5.zip -SOURCE_SUM=5e05d1a21e6766912f72391232e852e953f8fdcabc8d569fba2b84d3636abe32 + SOURCE_URL=https://github.com/tulir/mautrix-whatsapp/archive/v0.1.6.zip +SOURCE_SUM=c7f08d032e6e911f23c1e5ac13a5cbe64231b77f5dc6e6cea52c7f8d65532107 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=zip SOURCE_IN_SUBDIR=true diff --git a/conf/config.yaml b/conf/config.yaml index 4153d38..a2b3881 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -114,6 +114,8 @@ bridge: # Whether or not the bridge should send a notice to the user's management room when it retries connecting. # If false, it will only report when it stops retrying. report_connection_retry: true + # Whether or not the bridge should reconnect even if WhatsApp says another web client connected. + aggressive_reconnect: false # Maximum number of seconds to wait for chats to be sent at startup. # If this is too low and you have lots of chats, it could cause backfilling to fail. chat_list_wait: 30 @@ -144,6 +146,19 @@ bridge: # syncing the chat in any case. This setting will take priority # over both recovery_chat_sync_limit and initial_chat_sync_count. # Default is 3 days = 259200 seconds + # Whether or not portal info should be fetched from the server when syncing, + # instead of relying on finding any changes in the message history. + # If you get 599 errors often, you should try disabling this. + chat_meta_sync: true + # Whether or not puppet avatars should be fetched from the server even if an avatar is already set. + # If you get 599 errors often, you should try disabling this. + user_avatar_sync: true + # Whether or not Matrix users leaving groups should be bridged to WhatsApp + bridge_matrix_leave: true + # Maximum number of seconds since last message in chat to skip + # syncing the chat in any case. This setting will take priority + # over both recovery_chat_sync_limit and initial_chat_sync_count. + # Default is 3 days = 259200 seconds sync_max_chat_age: 259200 # Whether or not to sync with custom puppets to receive EDUs that @@ -174,6 +189,8 @@ bridge: # chat portal rooms. This can be useful if the previous field works fine, # but causes room avatar/name bugs. private_chat_portal_meta: false + # Whether or not Matrix m.notice-type messages should be bridged. + bridge_notices: true # Set this to true to tell the bridge to re-send m.bridge events to all rooms on the next run. # This field will automatically be changed back to false after it, # except if the config file is not writable. diff --git a/conf/systemd.service b/conf/systemd.service index 30624b1..1f696aa 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,5 +1,5 @@ [Unit] -Description=Matrix Whatsapp bridge +Description=Matrix-Whatsapp Bridge After=matrix-synapse.service [Service] @@ -10,5 +10,35 @@ ExecStart=/opt/yunohost/__APP__/mautrix-whatsapp -c=/opt/yunohost/__APP__/config Restart=always RestartSec=3 +#[Service] +#Type=exec +#User=__APP__ +#WorkingDirectory=/opt/yunohost/__APP__ +#ExecStart=/opt/yunohost/__APP__/mautrix-whatsapp -c=/opt/yunohost/__APP__/config.yaml >> /var/log/__APP__/log.log 2>&1 +#Restart=on-failure +#RestartSec=30s + +# Optional hardening to improve security +#ReadWritePaths=/opt/yunohost/__APP__ /var/log/__APP__/ +#NoNewPrivileges=yes +#MemoryDenyWriteExecute=true +#PrivateDevices=yes +#PrivateTmp=yes +#ProtectHome=yes +#ProtectSystem=strict +#ProtectControlGroups=true +#RestrictSUIDSGID=true +#RestrictRealtime=true +#LockPersonality=true +#ProtectKernelLogs=true +#ProtectKernelTunables=true +#ProtectHostname=true +#ProtectKernelModules=true +#PrivateUsers=true +#ProtectClock=true +#SystemCallArchitectures=native +#SystemCallErrorNumber=EPERM +#SystemCallFilter=@system-service + [Install] WantedBy=multi-user.target diff --git a/manifest.json b/manifest.json index 95ffe39..9a8a826 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "A WhatsApp puppeting bridge for Matrix/Synapse.", "fr": "Passerelle WhatsApp pour Matrix/Synapse." }, - "version": "0.1.5~ynh1", + "version": "0.1.6~ynh1", "url": "https://github.com/tulir/mautrix-whatsapp", "license": "AGPL-3.0-or-later", "maintainer": { diff --git a/scripts/change_url b/scripts/change_url deleted file mode 100644 index 17a1e41..0000000 --- a/scripts/change_url +++ /dev/null @@ -1,117 +0,0 @@ -#!/bin/bash - -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - -source _common.sh -source /usr/share/yunohost/helpers - -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH - -new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 - -# Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -# Add settings here as needed by your application -#db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#db_user=$db_name -#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -change_domain=0 -if [ "$old_domain" != "$new_domain" ] -then - change_domain=1 -fi - -change_path=0 -if [ "$old_path" != "$new_path" ] -then - change_path=1 -fi - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 - -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" - -#================================================= -# MODIFY URL IN NGINX CONF -#================================================= -ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1 - -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf - -# Change the path in the nginx config file -if [ $change_path -eq 1 ] -then - # Make a backup of the original nginx config file if modified - ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for nginx helper - domain="$old_domain" - path_url="$new_path" - # Create a dedicated nginx config - ynh_add_nginx_config -fi - -# Change the domain for nginx -if [ $change_domain -eq 1 ] -then - # Delete file checksum for the old conf file location - ynh_delete_file_checksum --file="$nginx_conf_path" - mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location - ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi - -#================================================= -# SPECIFIC MODIFICATIONS -#================================================= -# ... -#================================================= - -#================================================= -# GENERIC FINALISATION -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 - -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload - -#================================================= -# END OF SCRIPT -#================================================= - -ynh_script_progression --message="Change of URL completed for $app" --time --last diff --git a/scripts/install b/scripts/install index 002468c..f9c8941 100755 --- a/scripts/install +++ b/scripts/install @@ -217,7 +217,9 @@ ynh_replace_string --match_string=__DOMAIN__ --replace_string="https://$domain" ynh_replace_string --match_string=__SERVER_NAME__ --replace_string=$server_name --target_file="$mautrix_config_path" ynh_replace_string --match_string=__PORT__ --replace_string=$port --target_file="$mautrix_config_path" ynh_replace_string --match_string=__MAUTRIX_WHATSAPP_USER__ --replace_string=$mautrix_whatsapp_user --target_file="$mautrix_config_path" +ynh_print_OFF ynh_replace_string --match_string=__MAUTRIX_WHATSAPP_DB_PWD__ --replace_string=$mautrix_whatsapp_db_pwd --target_file="$mautrix_config_path" +ynh_print_ON ynh_replace_string --match_string=__MAUTRIX_WHATSAPP_DB_NAME__ --replace_string=$mautrix_whatsapp_db_name --target_file="$mautrix_config_path" ynh_replace_string --match_string=__WHATSAPPBOT__ --replace_string=$whatsappbot --target_file="$mautrix_config_path" if [ "$botusers" = "local" ] diff --git a/scripts/upgrade b/scripts/upgrade index b2ae846..39c5f26 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,6 +18,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) server_name=$(ynh_app_setting_get --app=$app --key=server_name) +port=$(ynh_app_setting_get --app=$app --key=port) whatsappbot=$(ynh_app_setting_get --app=$app --key=whatsappbot) synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance) app_service_registration_path=$(ynh_app_setting_get --app=$app --key=app_service_registration_path) @@ -29,6 +30,10 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) mautrix_config_path="$final_path/config.yaml" mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version) +ynh_print_OFF +mautrix_whatsapp_db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_whatsapp_db_pwd) +ynh_print_ON + #================================================= # SET CONSTANTS #================================================= @@ -157,14 +162,53 @@ ynh_system_user_create --username=$mautrix_whatsapp_user ynh_backup_if_checksum_is_different --file="$mautrix_config_path" ynh_backup_if_checksum_is_different --file="$app_service_registration_path/$app.yaml" +#================================================= +# SET MAUTRIX-WHATSAPP CONFIG +#================================================= +ynh_script_progression --message="Configuring Mautrix-WhatsApp..." --weight=2 + +# Configure Mautrix-WhatsApp + +# WARNING : theses command are used in INSTALL, UPGRADE, CONFIG, CHANGE-URL (4 times) +# For any update do it in all files + +mautrix_config_path="$final_path/config.yaml" + +#Copy example-config.yaml to config.yaml +cp ../conf/config.yaml "$mautrix_config_path" + +ynh_replace_string --match_string=__DOMAIN__ --replace_string="https://$domain" --target_file="$mautrix_config_path" +ynh_replace_string --match_string=__SERVER_NAME__ --replace_string=$server_name --target_file="$mautrix_config_path" +ynh_replace_string --match_string=__PORT__ --replace_string=$port --target_file="$mautrix_config_path" +ynh_replace_string --match_string=__MAUTRIX_WHATSAPP_USER__ --replace_string=$mautrix_whatsapp_user --target_file="$mautrix_config_path" +ynh_print_OFF +ynh_replace_string --match_string=__MAUTRIX_WHATSAPP_DB_PWD__ --replace_string=$mautrix_whatsapp_db_pwd --target_file="$mautrix_config_path" +ynh_print_ON +ynh_replace_string --match_string=__MAUTRIX_WHATSAPP_DB_NAME__ --replace_string=$mautrix_whatsapp_db_name --target_file="$mautrix_config_path" +ynh_replace_string --match_string=__WHATSAPPBOT__ --replace_string=$whatsappbot --target_file="$mautrix_config_path" +if [ "$botusers" = "local" ] +then +ynh_replace_string --match_string=__BOTUSERS__ --replace_string=$server_name --target_file="$mautrix_config_path" +elif [ "$botusers" = "admin" ] +then +ynh_replace_string --match_string=__BOTUSERS__ --replace_string=$botadmin --target_file="$mautrix_config_path" +else +ynh_replace_string --match_string=__BOTUSERS__ --replace_string=$botusers --target_file="$mautrix_config_path" +fi +ynh_replace_string --match_string=__BOTADMIN__ --replace_string=$botadmin --target_file="$mautrix_config_path" +ynh_replace_string --match_string=__ENABLE_RELAYBOT__ --replace_string="true" --target_file="$mautrix_config_path" +ynh_replace_string --match_string=__RELAYBOT_MANAGEMENT_ROOM__ --replace_string="highwaytohell" --target_file="$mautrix_config_path" +ynh_replace_string --match_string=__RELAYBOT_INVITE__ --replace_string=$botadmin --target_file="$mautrix_config_path" +ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file="$mautrix_config_path" +ynh_replace_string --match_string=__LOG_FORMAT__ --replace_string="log.log" --target_file="$mautrix_config_path" + # Options: debug, info, warn, error, fatal +ynh_replace_string --match_string=__LOG_LEVEL__ --replace_string="error" --target_file="$mautrix_config_path" + #================================================= # REGISTER SYNAPSE APP-SERVICE #================================================= $final_path/mautrix-whatsapp -g -c $mautrix_config_path -r $app_service_registration_path/$app.yaml -#$as_token=; -#$hs_token=; -#ynh_replace_string --match_string=__AS_TOKEN__ --replace_string="$as_token" --target_file=$app_service_registration_path/$app.yaml -#ynh_replace_string --match_string=__HS_TOKEN__ --replace_string="$hs_token" --target_file=$app_service_registration_path/$app.yaml + /opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \ || ynh_die "Synapse can't restart with the appservice configuration" # Handled by synapse: synapse_ynh adds all registration files added in $app_service_registration_path to the app_service_config_files list diff --git a/sources/extra_files/app/example-config.yaml b/sources/extra_files/app/example-config.yaml deleted file mode 100644 index 2ed2f4c..0000000 --- a/sources/extra_files/app/example-config.yaml +++ /dev/null @@ -1,187 +0,0 @@ -# Homeserver details. -homeserver: - # The address that this appservice can use to connect to the homeserver. - address: https://example.com - # The domain of the homeserver (for MXIDs, etc). - domain: example.com - -# Application service host/registration related details. -# Changing these values requires regeneration of the registration. -appservice: - # The address that the homeserver can use to connect to this appservice. - address: http://localhost:29318 - - # The hostname and port where this appservice should listen. - hostname: 0.0.0.0 - port: 29318 - - # Database config. - database: - # The database type. "sqlite3" and "postgres" are supported. - type: sqlite3 - # The database URI. - # SQLite: File name is enough. https://github.com/mattn/go-sqlite3#connection-string - # Postgres: Connection string. For example, postgres://user:password@host/database - uri: mautrix-whatsapp.db - # Maximum number of connections. Mostly relevant for Postgres. - max_open_conns: 20 - max_idle_conns: 2 - - # Settings for provisioning API - provisioning: - # Prefix for the provisioning API paths. - prefix: /_matrix/provision/v1 - # Shared secret for authentication. If set to "disable", the provisioning API will be disabled. - shared_secret: disable - - # The unique ID of this appservice. - id: whatsapp - # Appservice bot details. - bot: - # Username of the appservice bot. - username: whatsappbot - # Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty - # to leave display name/avatar as-is. - displayname: WhatsApp bridge bot - avatar: mxc://maunium.net/NeXNQarUbrlYBiPCpprYsRqr - - # Authentication tokens for AS <-> HS communication. Autogenerated; do not modify. - as_token: "This value is generated when generating the registration" - hs_token: "This value is generated when generating the registration" - -# Bridge config -bridge: - # Localpart template of MXIDs for WhatsApp users. - # {{.}} is replaced with the phone number of the WhatsApp user. - username_template: whatsapp_{{.}} - # Displayname template for WhatsApp users. - # {{.Notify}} - nickname set by the WhatsApp user - # {{.Jid}} - phone number (international format) - # The following variables are also available, but will cause problems on multi-user instances: - # {{.Name}} - display name from contact list - # {{.Short}} - short display name from contact list - displayname_template: "{{if .Notify}}{{.Notify}}{{else}}{{.Jid}}{{end}} (WA)" - # Localpart template for per-user room grouping community IDs. - # On startup, the bridge will try to create these communities, add all of the specific user's - # portals to the community, and invite the Matrix user to it. - # (Note that, by default, non-admins might not have your homeserver's permission to create - # communities.) - # {{.Localpart}} is the MXID localpart and {{.Server}} is the MXID server part of the user. - community_template: whatsapp_{{.Localpart}}={{.Server}} - - # WhatsApp connection timeout in seconds. - connection_timeout: 20 - # Number of times to regenerate QR code when logging in. - # The regenerated QR code is sent as an edit and essentially multiplies the login timeout (20 seconds) - login_qr_regen_count: 2 - # Maximum number of times to retry connecting on connection error. - max_connection_attempts: 3 - # Number of seconds to wait between connection attempts. - # Negative numbers are exponential backoff: -connection_retry_delay + 1 + 2^attempts - connection_retry_delay: -1 - # Whether or not the bridge should send a notice to the user's management room when it retries connecting. - # If false, it will only report when it stops retrying. - report_connection_retry: true - # Maximum number of seconds to wait for chats to be sent at startup. - # If this is too low and you have lots of chats, it could cause backfilling to fail. - chat_list_wait: 30 - # Maximum number of seconds to wait to sync portals before force unlocking message processing. - # If this is too low and you have lots of chats, it could cause backfilling to fail. - portal_sync_wait: 600 - - # Whether or not to send call start/end notices to Matrix. - call_notices: - start: true - end: true - - # Number of chats to sync for new users. - initial_chat_sync_count: 10 - # Number of old messages to fill when creating new portal rooms. - initial_history_fill_count: 20 - # Maximum number of chats to sync when recovering from downtime. - # Set to -1 to sync all new chats during downtime. - recovery_chat_sync_limit: -1 - # Whether or not to sync history when recovering from downtime. - recovery_history_backfill: true - # Maximum number of seconds since last message in chat to skip - # syncing the chat in any case. This setting will take priority - # over both recovery_chat_sync_limit and initial_chat_sync_count. - # Default is 3 days = 259200 seconds - sync_max_chat_age: 259200 - - # Whether or not to sync with custom puppets to receive EDUs that - # are not normally sent to appservices. - sync_with_custom_puppets: true - # Shared secret for https://github.com/devture/matrix-synapse-shared-secret-auth - # - # If set, custom puppets will be enabled automatically for local users - # instead of users having to find an access token and run `login-matrix` - # manually. - login_shared_secret: null - - # Whether or not to invite own WhatsApp user's Matrix puppet into private - # chat portals when backfilling if needed. - # This always uses the default puppet instead of custom puppets due to - # rate limits and timestamp massaging. - invite_own_puppet_for_backfilling: true - # Whether or not to explicitly set the avatar and room name for private - # chat portal rooms. This can be useful if the previous field works fine, - # but causes room avatar/name bugs. - private_chat_portal_meta: false - - # Allow invite permission for user. User can invite any bots to room with whatsapp - # users (private chat and groups) - allow_user_invite: false - - # The prefix for commands. Only required in non-management rooms. - command_prefix: "!wa" - - # Permissions for using the bridge. - # Permitted values: - # relaybot - Talk through the relaybot (if enabled), no access otherwise - # user - Access to use the bridge to chat with a WhatsApp account. - # admin - User level and some additional administration tools - # Permitted keys: - # * - All Matrix users - # domain - All users on that homeserver - # mxid - Specific user - permissions: - "*": relaybot - "example.com": user - "@admin:example.com": admin - - relaybot: - # Whether or not relaybot support is enabled. - enabled: false - # The management room for the bot. This is where all status notifications are posted and - # in this room, you can use `!wa ` instead of `!wa relaybot `. Omitting - # the command prefix completely like in user management rooms is not possible. - management: !foo:example.com - # List of users to invite to all created rooms that include the relaybot. - invites: [] - # The formats to use when sending messages to WhatsApp via the relaybot. - message_formats: - m.text: "{{ .Sender.Displayname }}: {{ .Message }}" - m.notice: "{{ .Sender.Displayname }}: {{ .Message }}" - m.emote: "* {{ .Sender.Displayname }} {{ .Message }}" - m.file: "{{ .Sender.Displayname }} sent a file" - m.image: "{{ .Sender.Displayname }} sent an image" - m.audio: "{{ .Sender.Displayname }} sent an audio file" - m.video: "{{ .Sender.Displayname }} sent a video" - m.location: "{{ .Sender.Displayname }} sent a location" - -# Logging config. -logging: - # The directory for log files. Will be created if not found. - directory: ./logs - # Available variables: .Date for the file date and .Index for different log files on the same day. - file_name_format: "{{.Date}}-{{.Index}}.log" - # Date format for file names in the Go time format: https://golang.org/pkg/time/#pkg-constants - file_date_format: 2006-01-02 - # Log file permissions. - file_mode: 0600 - # Timestamp format for log entries in the Go time format. - timestamp_format: Jan _2, 2006 15:04:05 - # Minimum severity for log messages. - # Options: debug, info, warn, error, fatal - print_level: debug