diff --git a/README.md b/README.md
index b59f872..4bc2f65 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ It shall NOT be edited by hand.
# Matrix-WhatsApp bridge for YunoHost
-[](https://dash.yunohost.org/appci/app/mautrix_whatsapp)  
+[](https://dash.yunohost.org/appci/app/mautrix_whatsapp)  
[](https://install-app.yunohost.org/?app=mautrix_whatsapp)
*[Lire ce readme en français.](./README_fr.md)*
diff --git a/README_fr.md b/README_fr.md
index 121ca8a..b0681c4 100644
--- a/README_fr.md
+++ b/README_fr.md
@@ -5,15 +5,15 @@ It shall NOT be edited by hand.
# Matrix-WhatsApp bridge pour YunoHost
-[](https://dash.yunohost.org/appci/app/mautrix_whatsapp)  
+[](https://dash.yunohost.org/appci/app/mautrix_whatsapp)  
[](https://install-app.yunohost.org/?app=mautrix_whatsapp)
*[Read this readme in english.](./README.md)*
-> *Ce package vous permet d'installer Matrix-WhatsApp bridge 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.*
+> *Ce package vous permet d’installer Matrix-WhatsApp bridge 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
+## Vue d’ensemble
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.
@@ -106,9 +106,9 @@ Si vous devez téléverser vos fichiers log quelque-part, soyez avertis qu'ils c
## Documentations et ressources
-* Site officiel de l'app :
-* Documentation officielle de l'admin :
-* Dépôt de code officiel de l'app :
+* Site officiel de l’app :
+* Documentation officielle de l’admin :
+* Dépôt de code officiel de l’app :
* Documentation YunoHost pour cette app :
* Signaler un bug :
@@ -124,4 +124,4 @@ ou
sudo yunohost app upgrade mautrix_whatsapp -u https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh/tree/testing --debug
```
-**Plus d'infos sur le packaging d'applications :**
+**Plus d’infos sur le packaging d’applications :**
\ No newline at end of file
diff --git a/conf/config.yaml b/conf/config.yaml
index 4f40caa..43ad784 100644
--- a/conf/config.yaml
+++ b/conf/config.yaml
@@ -15,7 +15,7 @@ homeserver:
# Endpoint for reporting per-message status.
message_send_checkpoint_endpoint: null
# Does the homeserver support https://github.com/matrix-org/matrix-spec-proposals/pull/2246?
- async_media: false
+ async_media: __ASYNC_MEDIA__
# Application service host/registration related details.
# Changing these values requires regeneration of the registration.
@@ -56,13 +56,13 @@ appservice:
username: __BOTNAME__
# 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
+ displayname: __DISPLAYNAME__
+ avatar: __AVATAR__
# Whether or not to receive ephemeral events via appservice transactions.
# Requires MSC2409 support (i.e. Synapse 1.22+).
# You should disable bridge -> sync_with_custom_puppets when this is enabled.
- ephemeral_events: true
+ ephemeral_events: __EPHEMERAL_EVENTS__
# Should incoming events be handled asynchronously?
# This may be necessary for large public instances with lots of messages going through.
@@ -79,24 +79,24 @@ segment_key: null
# Prometheus config.
metrics:
# Enable prometheus metrics?
- enabled: false
+ enabled: __ENABLE_METRICS__
# IP and port where the metrics listener should be. The path is always /metrics
- listen: 127.0.0.1:8001
+ listen: __LISTEN_PORT__
# Config for things that are directly sent to WhatsApp.
whatsapp:
# Device name that's shown in the "WhatsApp Web" section in the mobile app.
- os_name: Mautrix-WhatsApp bridge
+ os_name: __OS_NAME__
# Browser name that determines the logo shown in the mobile app.
# Must be "unknown" for a generic icon or a valid browser name if you want a specific icon.
# List of valid browser names: https://github.com/tulir/whatsmeow/blob/8b34d886d543b72e5f4699cf5b2797f68d598f78/binary/proto/def.proto#L38-L51
- browser_name: unknown
+ browser_name: __BROWSER_NAME__
# Bridge config
bridge:
# Localpart template of MXIDs for WhatsApp users.
# {{.}} is replaced with the phone number of the WhatsApp user.
- username_template: whatsapp_{{.}}
+ username_template: __USERNAME_TEMPLATE__
# Displayname template for WhatsApp users.
# {{.PushName}} - nickname set by the WhatsApp user
# {{.BusinessName}} - validated WhatsApp business name
@@ -107,9 +107,9 @@ bridge:
displayname_template: "{{if .BusinessName}}{{.BusinessName}}{{else if .PushName}}{{.PushName}}{{else}}{{.JID}}{{end}} (WA)"
# Should the bridge create a space for each logged-in user and add bridged rooms to it?
# Users who logged in before turning this on should run `!wa sync space` to create and fill the space for the first time.
- personal_filtering_spaces: false
+ personal_filtering_spaces: __PERSONAL_FILTERING_SPACES__
# Should the bridge send a read receipt from the bridge bot when a message has been sent to WhatsApp?
- delivery_receipts: false
+ delivery_receipts: __DELIVERY_RECEIPTS__
# Whether the bridge should send the message status as a custom com.beeper.message_send_status event.
message_status_events: false
# Whether the bridge should send error notices via m.notice events when a message fails to bridge.
@@ -226,7 +226,7 @@ bridge:
# Send the presence as "available" to whatsapp when users start typing on a portal.
# This works as a workaround for homeservers that do not support presence, and allows
# users to see when the whatsapp user on the other side is typing during a conversation.
- send_presence_on_typing: false
+ send_presence_on_typing: __SEND_PRESENCE_ON_TYPING__
# Should the bridge always send "active" delivery receipts (two gray ticks on WhatsApp)
# even if the user isn't marked as online (e.g. when presence bridging isn't enabled)?
#
@@ -298,7 +298,7 @@ bridge:
# Should the bridge detect URLs in outgoing messages, ask the homeserver to generate a preview,
# and send it to WhatsApp? URL previews can always be sent using the `com.beeper.linkpreviews`
# key in the event content even if this is disabled.
- url_previews: false
+ url_previews: __URL_PREVIEWS__
# Send captions in the same message as images. This will send data compatible with both MSC2530 and MSC3552.
# This is currently not supported in most clients.
caption_in_message: false
@@ -342,11 +342,11 @@ bridge:
# Default to encryption, force-enable encryption in all portals the bridge creates
# This will cause the bridge bot to be in private chats for the encryption to work properly.
# It is recommended to also set private_chat_portal_meta to true when using this.
- default: false
+ default: __ENCRYPTION_DEFAULT__
# Whether to use MSC2409/MSC3202 instead of /sync long polling for receiving encryption-related data.
appservice: false
# Require encryption, drop any unencrypted messages.
- require: false
+ require: __ENCRYPTION_REQUIRE__
# Enable key sharing? If enabled, key requests for rooms where users are in will be fulfilled.
# You must use a client that supports requesting keys from other users to use this feature.
allow_key_sharing: false
@@ -403,20 +403,18 @@ bridge:
# domain - All users on that homeserver
# mxid - Specific user
permissions:
- "*": relay
- #"example.com": user
- "__BOTUSERS__": user
- #"@admin:example.com": admin
- "__BOTADMIN__": admin
+ "__LISTRELAY__": relay
+ "__LISTUSER__": user
+ "__LISTADMIN__": admin
# Settings for relay mode
relay:
# Whether relay mode should be allowed. If allowed, `!wa set-relay` can be used to turn any
# authenticated user into a relaybot for that chat.
#enabled: false
- enabled: true
+ enabled: __ENABLE_RELAYBOT__
# Should only admins be allowed to set themselves as relay users?
- admin_only: true
+ admin_only: __ADMIN_ONLY__
# The formats to use when sending messages to WhatsApp via the relaybot.
message_formats:
m.text: "{{ .Sender.Displayname }}: {{ .Message }}"
@@ -445,4 +443,4 @@ logging:
timestamp_format: "Jan _2, 2006 15:04:05"
# Minimum severity for log messages printed to stdout/stderr. This doesn't affect the log file.
# Options: debug, info, warn, error, fatal
- print_level: INFO
+ print_level: __PRINT_LEVEL__
diff --git a/config_panel.toml b/config_panel.toml
new file mode 100644
index 0000000..27bff09
--- /dev/null
+++ b/config_panel.toml
@@ -0,0 +1,219 @@
+version = "1.0"
+
+[main]
+name = "Main Settings"
+services = ["__APP__"]
+
+ [main.permissions]
+ name = "Permissions for using the bridge"
+
+ [main.permissions.helptext]
+ ask = '''
+ Roles with Increasing Power: Relay0.2.1
-ynh_secure_remove --file="$final_path"/community.go
-ynh_secure_remove --file="$final_path"/database/upgrades/2019-05-23-protoupgrade.go
-ynh_secure_remove --file="$final_path"/database/upgrades/2019-05-16-message-delete-cascade.go
-src_path="$final_path"_src
-ynh_secure_remove --file="$src_path"
-src_path="$final_path"/src
-ynh_secure_remove --file="$src_path"
-
-# Upgrade from >0.2.0
-botname=$(ynh_app_setting_get --app=$app --key=botname)
-db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
-
-# Upgrade from <=0.2.0
+# DB Backup missing because of wrong Upgrade from <=0.2.0
if [ -z "$botname" ]
then
botname=$(ynh_app_setting_get --app=$app --key=whatsappbot)
@@ -89,7 +99,7 @@ then
fi
if [ -z "$db_name" ]
then
- db_name=$(ynh_app_setting_get --app=$app --key=$app)
+ db_name=$(ynh_app_setting_get --app=$app --key=mautrix_whatsapp_db_name)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi
if [ -z "$db_pwd" ]
@@ -97,26 +107,126 @@ then
db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_whatsapp_db_pwd)
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
fi
+ynh_app_setting_delete --app=$app --key=whatsappbot
+ynh_app_setting_delete --app=$app --key=mautrix_whatsapp_db_name
+ynh_app_setting_delete --app=$app --key=mautrix_whatsapp_db_pwd
-# If appserviceid doesn't exist, create it
-if [ -z "$appserviceid" ]
+# SET STANDARD SETTINGS FROM DEFAULT CONFIG
+
+if [ -z "$async_media" ]
then
- appserviceid=$app
- ynh_app_setting_set --app=$app --key=appserviceid --value=$appserviceid
+ async_media="false"
+ ynh_app_setting_set --app=$app --key=async_media --value=$async_media
+fi
+if [ -z "$displayname" ]
+then
+ displayname="WhatsApp bridge bot"
+ ynh_app_setting_set --app=$app --key=displayname --value=$displayname
+fi
+if [ -z "$avatar" ]
+then
+ avatar="mxc://maunium.net/NeXNQarUbrlYBiPCpprYsRqr"
+ ynh_app_setting_set --app=$app --key=avatar --value=$avatar
+fi
+if [ -z "$ephemeral_events" ]
+then
+ ephemeral_events="true"
+ ynh_app_setting_set --app=$app --key=ephemeral_events --value=$ephemeral_events
+fi
+if [ -z "$enable_metrics" ]
+then
+ enable_metrics="false"
+ ynh_app_setting_set --app=$app --key=enable_metrics --value=$enable_metrics
+fi
+if [ -z "$listen_port" ]
+then
+ listen_port="127.0.0.1:8001"
+ ynh_app_setting_set --app=$app --key=listen_port --value=$listen_port
+fi
+if [ -z "$os_name" ]
+then
+ os_name="Mautrix-WhatsApp bridge"
+ ynh_app_setting_set --app=$app --key=os_name --value=$os_name
+fi
+if [ -z "$browser_name" ]
+then
+ browser_name="unknown"
+ ynh_app_setting_set --app=$app --key=browser_name --value=$browser_name
+fi
+if [ -z "$username_template" ]
+then
+ username_template="whatsapp_{{.}}"
+ ynh_app_setting_set --app=$app --key=username_template --value=$username_template
+fi
+if [ -z "$personal_filtering_spaces" ]
+then
+ personal_filtering_spaces="false"
+ ynh_app_setting_set --app=$app --key=personal_filtering_spaces --value=$personal_filtering_spaces
+fi
+if [ -z "$delivery_receipts" ]
+then
+ delivery_receipts="false"
+ ynh_app_setting_set --app=$app --key=delivery_receipts --value=$delivery_receipts
+fi
+if [ -z "$send_presence_on_typing" ]
+then
+ send_presence_on_typing="false"
+ ynh_app_setting_set --app=$app --key=send_presence_on_typing --value=$send_presence_on_typing
+fi
+if [ -z "$url_previews" ]
+then
+ url_previews="false"
+ ynh_app_setting_set --app=$app --key=url_previews --value=$url_previews
+fi
+if [ -z "$encryption_default" ]
+then
+ encryption_default="false"
+ ynh_app_setting_set --app=$app --key=encryption_default --value=$encryption_default
+fi
+if [ -z "$encryption_require" ]
+then
+ encryption_require="false"
+ ynh_app_setting_set --app=$app --key=encryption_require --value=$encryption_require
+fi
+if [ -z "$enable_relaybot" ]
+then
+ enable_relaybot="true"
+ ynh_app_setting_set --app=$app --key=enable_relaybot --value=$enable_relaybot
+fi
+if [ -z "$admin_only" ]
+then
+ admin_only="true"
+ ynh_app_setting_set --app=$app --key=admin_only --value=$admin_only
+fi
+if [ -z "$print_level" ]
+then
+ print_level="info"
+ ynh_app_setting_set --app=$app --key=print_level --value=$print_level
+fi
+if [ -z "$listrelay" ]
+then
+ listrelay="*"
+ ynh_app_setting_set --app=$app --key=listrelay --value=$listrelay
+fi
+if [ -z "$enable_relaybot" ]
+then
+ enable_relaybot="true"
+ ynh_app_setting_set --app=$app --key=enable_relaybot --value=$enable_relaybot
fi
+if [ -z "$listuser" ]
+then
+ listuser=$(ynh_app_setting_get --app=$app --key=botusers)
+ ynh_app_setting_set --app=$app --key=listuser --value=$listuser
+ ynh_app_setting_delete --app=$app --key=botusers
+fi
-# If db_name doesn't exist, create it
-#if [ -z "$mautrix_whatsapp_db_name" ]; then
-# mautrix_whatsapp_db_name=$(ynh_sanitize_dbid --db_name=$app)
-# ynh_app_setting_set --app=$app --key=db_name --value=$mautrix_whatsapp_db_name
-#fi
-
-# If final_path doesn't exist, create it
-#if [ -z "$final_path" ]; then
-# final_path=/opt/yunohost/$app
-# ynh_app_setting_set --app=$app --key=final_path --value=$final_path
-#fi
+if [ -z "$listadmin" ]
+then
+ listadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
+ ynh_app_setting_set --app=$app --key=listadmin --value=$listadmin
+ ynh_app_setting_delete --app=$app --key=botadmin
+fi
#=================================================
# CREATE DEDICATED USER
@@ -161,11 +271,28 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=2
+# reset permissions to be able to apply_permissions with app_setting values after upgrade
+listrelay_=$listrelay
+listuser_=$listuser
+listadmin_=$listadmin
+listrelay="*"
+listuser="@user:domain.tld"
+listadmin="@admin:domain.tld"
+
ynh_add_config --template="../conf/config.yaml" --destination="$final_path/config.yaml"
chmod 400 "$final_path/config.yaml"
chown $app:$app "$final_path/config.yaml"
+listrelay=$listrelay_
+listuser=$listuser_
+listadmin=$listadmin_
+# MIGRATION from previous version without config panel -> config panel does not exist yet, so we upgrade the config after starting the systemd service
+# apply_permissions to have correct syntax in config file
+#yunohost app config set $app main.permissions.listrelay -v "$listrelay"
+#yunohost app config set $app main.permissions.listuser -v "$listuser"
+#yunohost app config set $app main.permissions.listadmin -v "$listadmin"
+
#=================================================
# REGISTER SYNAPSE APP-SERVICE
#=================================================
@@ -215,6 +342,12 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start"
+# MIGRATION from previous version without config panel -> config panel does not exist yet, so we upgrade the config after starting the systemd service
+# apply_permissions to have correct syntax in config file
+yunohost app config set $app main.permissions.listrelay -v "$listrelay"
+yunohost app config set $app main.permissions.listuser -v "$listuser"
+yunohost app config set $app main.permissions.listadmin -v "$listadmin"
+
#=================================================
# END OF SCRIPT
#=================================================