mirror of
https://github.com/YunoHost-Apps/mautrix_signal_ynh.git
synced 2024-09-03 19:46:07 +02:00
~ sync with mautrix_whatsapp
This commit is contained in:
parent
43696caa52
commit
91ae91456e
5 changed files with 324 additions and 35 deletions
|
@ -53,18 +53,18 @@ appservice:
|
|||
max_size: 10
|
||||
|
||||
# The unique ID of this appservice.
|
||||
id: __BOTNAME__
|
||||
id: __APPSERVICEID__
|
||||
# Username of the appservice bot.
|
||||
bot_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.
|
||||
bot_displayname: Signal bridge bot
|
||||
bot_avatar: mxc://maunium.net/wPJgTQbZOtpBFmDNkiNEMDUp
|
||||
bot_displayname: __DISPLAYNAME__
|
||||
bot_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: false
|
||||
ephemeral_events: __EPHEMERAL_EVENTS__
|
||||
|
||||
# Authentication tokens for AS <-> HS communication. Autogenerated; do not modify.
|
||||
as_token: "This value is generated when generating the registration"
|
||||
|
@ -72,8 +72,8 @@ appservice:
|
|||
|
||||
# Prometheus telemetry config. Requires prometheus-client to be installed.
|
||||
metrics:
|
||||
enabled: false
|
||||
listen_port: 8000
|
||||
enabled: __ENABLE_METRICS__
|
||||
listen_port: __METRICS_LISTEN_PORT__
|
||||
|
||||
# Manhole config.
|
||||
manhole:
|
||||
|
@ -103,17 +103,17 @@ signal:
|
|||
# Whether or not message attachments should be removed from disk after they're bridged.
|
||||
remove_file_after_handling: true
|
||||
# Whether or not users can register a primary device
|
||||
registration_enabled: true
|
||||
registration_enabled: __REGISTRATION_ENABLED__
|
||||
# Whether or not to enable disappearing messages in groups. If enabled, then the expiration
|
||||
# time of the messages will be determined by the first users to read the message, rather
|
||||
# than individually. If the bridge has a single user, this can be turned on safely.
|
||||
enable_disappearing_messages_in_groups: false
|
||||
enable_disappearing_messages_in_groups: __ENABLE_DISAPPEARING_MESSAGES_IN_GROUPS__
|
||||
|
||||
# Bridge config
|
||||
bridge:
|
||||
# Localpart template of MXIDs for Signal users.
|
||||
# {userid} is replaced with an identifier for the Signal user.
|
||||
username_template: "sg_{userid}"
|
||||
username_template: __USERNAME_TEMPLATE__
|
||||
# Displayname template for Signal users.
|
||||
# {displayname} is replaced with the displayname of the Signal user, which is the first
|
||||
# available variable in displayname_preference. The variables in displayname_preference
|
||||
|
@ -124,7 +124,7 @@ bridge:
|
|||
#
|
||||
# Multi-user instances are recommended to disallow contact list names, as otherwise there can
|
||||
# be conflicts between names from different users' contact lists.
|
||||
contact_list_names: disallow
|
||||
contact_list_names: __CONTACT_LIST_NAMES__
|
||||
# Available variables: full_name, first_name, last_name, phone, uuid
|
||||
displayname_preference:
|
||||
- full_name
|
||||
|
@ -157,7 +157,7 @@ bridge:
|
|||
example.com: foobar
|
||||
# Whether or not created rooms should have federation enabled.
|
||||
# If false, created portal rooms will never be federated.
|
||||
federate_rooms: true
|
||||
federate_rooms: __FEDERATE_ROOMS__
|
||||
# End-to-bridge encryption support options. You must install the e2be optional dependency for
|
||||
# this to work. See https://docs.mau.fi/bridges/general/end-to-bridge-encryption.html
|
||||
encryption:
|
||||
|
@ -165,7 +165,7 @@ bridge:
|
|||
allow: __ENCRYPTION__
|
||||
# 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.
|
||||
default: false
|
||||
default: __ENCRYPTION_DEFAULT__
|
||||
# Options for automatic key sharing.
|
||||
key_sharing:
|
||||
# Enable key sharing? If enabled, key requests for rooms where users are in will be fulfilled.
|
||||
|
@ -287,5 +287,5 @@ logging:
|
|||
aiohttp:
|
||||
level: INFO
|
||||
root:
|
||||
level: INFO
|
||||
level: __PRINT_LEVEL__
|
||||
handlers: [file, console]
|
||||
|
|
|
@ -1,23 +1,146 @@
|
|||
version = "1.0"
|
||||
|
||||
[encryption]
|
||||
name = "Encryption"
|
||||
[appservice]
|
||||
name = "Application service configuration"
|
||||
services = ["__APP__"]
|
||||
[encryption.config]
|
||||
name = "Encryption settings"
|
||||
|
||||
[encryption.config.encryption]
|
||||
ask = "Enable encryption"
|
||||
[appservice.config]
|
||||
name = "General configuration"
|
||||
|
||||
[appservice.config.ephemeral_events]
|
||||
ask = "Whether or not to receive ephemeral events via appservice transactions"
|
||||
type = "boolean"
|
||||
yes = "true"
|
||||
no = "false"
|
||||
help = "Requires MSC2409 support (i.e. Synapse 1.22+). You should disable bridge -> sync_with_custom_puppets when this is enabled"
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
|
||||
[appservice.config.registration_enabled]
|
||||
ask = "Whether or not users can register a primary device"
|
||||
type = "boolean"
|
||||
yes = "true"
|
||||
no = "false"
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
|
||||
[appservice.config.enable_disappearing_messages_in_groups]
|
||||
ask = "Whether or not to enable disappearing messages in groups"
|
||||
type = "boolean"
|
||||
yes = "true"
|
||||
no = "false"
|
||||
help = "If the bridge has a single user, this can be turned on safely. If enabled, then the expiration time of the messages will be determined by the first users to read the message, rather than individually."
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
|
||||
[appservice.config.print_level]
|
||||
ask = "Root logging print level"
|
||||
type = "select"
|
||||
choices = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL" or "NOTSET"]
|
||||
help = "NOTSET means that all messages will be logged: https://docs.python.org/3.6/library/logging.config.html#configuration-file-format"
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
|
||||
[appservice.bot]
|
||||
name = "Appservice bot configuration"
|
||||
|
||||
[appservice.bot.appserviceid]
|
||||
ask = "The unique ID of this appservice."
|
||||
type = "string"
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
|
||||
[appservice.bot.botname]
|
||||
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 = ":__FINALPATH__/config.yaml"
|
||||
|
||||
[appservice.bot.displayname]
|
||||
ask = "Display name for bot"
|
||||
type = "string"
|
||||
help = "Set to 'remove' to remove display name, leave empty to leave display name as-is"
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
|
||||
[appservice.bot.avatar]
|
||||
ask = "Avatar for bot"
|
||||
type = "string"
|
||||
help = "Set to 'remove' to remove avatar, leave empty to leave avatar as-is"
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
|
||||
[bridge]
|
||||
name = "Bridge"
|
||||
services = ["__APP__"]
|
||||
[bridge.config]
|
||||
name = "Bridge settings"
|
||||
|
||||
[bridge.config.username_template]
|
||||
ask = "Localpart template of MXIDs for Signal users."
|
||||
type = "string"
|
||||
help = "{userid} is replaced with an identifier for the Signal user."
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
|
||||
[bridge.config.contact_list_names]
|
||||
ask = "Whether or not contact list displaynames should be used."
|
||||
type = select
|
||||
choices = ["disallow", "allow", "prefer"]
|
||||
help = "Multi-user instances are recommended to disallow contact list names, as otherwise there can be conflicts between names from different users' contact lists."
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
|
||||
[bridge.config.federate_rooms]
|
||||
ask = "Whether or not created rooms should have federation enabled."
|
||||
type = "boolean"
|
||||
yes = "true"
|
||||
no = "false"
|
||||
help = "Enables end to bridge encryption"
|
||||
bind = "encryption>allow:__FINALPATH__/config.yaml"
|
||||
help = "If false, created portal rooms will never be federated."
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
|
||||
[bridge.config.encryption]
|
||||
ask = "Allow end to bridge encryption?"
|
||||
type = "boolean"
|
||||
yes = "true"
|
||||
no = "false"
|
||||
help = "For the bridge to work in group chat rooms with e2ee enabled."
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
|
||||
[encryption.config.default]
|
||||
ask = "Default to encryption"
|
||||
[bridge.config.encryption_default]
|
||||
ask = "Force-enable encryption in all portals the bridge creates?"
|
||||
type = "boolean"
|
||||
yes = "true"
|
||||
no = "false"
|
||||
help = "Default to encryption, force-enable encryption in all portals the bridge creates"
|
||||
bind = "encryption>default:__FINALPATH__/config.yaml"
|
||||
help = "This will cause the bridge bot to be in private chats for the encryption to work properly."
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
|
||||
[bridge.config.enable_relaybot]
|
||||
ask = "Whether relay mode should be allowed."
|
||||
type = "boolean"
|
||||
yes = "true"
|
||||
no = "false"
|
||||
help = "If allowed, `!sg set-relay` can be used to turn any authenticated user into a relaybot for that chat."
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
|
||||
[usermanagement]
|
||||
name = "User management"
|
||||
services = ["__APP__"]
|
||||
|
||||
[usermanagement.config]
|
||||
name = "User management"
|
||||
|
||||
[usermanagement.config.helptext]
|
||||
ask = "Allowed values:\n  * - All Matrix users\n  domain.tld - All users on homeserver\n  mxid (@user:matrix.org) - Specific Matrix user"
|
||||
type = "markdown"
|
||||
|
||||
[usermanagement.config.listuser]
|
||||
ask = "Users"
|
||||
type = "tags"
|
||||
visible = "role == 'user'"
|
||||
|
||||
[usermanagement.config.listadmin]
|
||||
ask = "Admins"
|
||||
type = "tags"
|
||||
visible = "role == 'admin'"
|
||||
|
||||
[usermanagement.config.listrelay]
|
||||
ask = "Relay users"
|
||||
type = "tags"
|
||||
visible = "role == 'relay'"
|
||||
|
||||
[usermanagement.config.role]
|
||||
ask = "Role"
|
||||
type = "select"
|
||||
choices = ["user", "admin", "relay"]
|
||||
|
|
|
@ -34,4 +34,63 @@ function get__encryption {
|
|||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
||||
function get__listuser {
|
||||
existingUsers=$(grep -- "\".*: user" "$final_path/config.yaml" | sed -r 's/: user//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr '\n' ',')
|
||||
|
||||
cat <<EOF
|
||||
value: '$existingUsers'
|
||||
EOF
|
||||
}
|
||||
|
||||
function get__listrelay {
|
||||
existingRelayUsers=$(grep -- "\".*: relay" "$final_path/config.yaml" | sed -r 's/: relay//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr '\n' ',')
|
||||
|
||||
cat <<EOF
|
||||
value: '$existingRelayUsers'
|
||||
EOF
|
||||
}
|
||||
|
||||
function get__listadmin {
|
||||
existingAdmins=$(grep -- "\".*: admin" "$final_path/config.yaml" | sed -r 's/: admin//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr '\n' ',')
|
||||
|
||||
cat <<EOF
|
||||
value: '$existingAdmins'
|
||||
EOF
|
||||
}
|
||||
|
||||
function get__role {
|
||||
cat <<EOF
|
||||
choices: ["admin", "user", "relay"]
|
||||
default: "user"
|
||||
EOF
|
||||
}
|
||||
|
||||
function set__role {
|
||||
set -o noglob # Disable globbing to avoid expansions when passing * as value.
|
||||
declare values="list$role"
|
||||
newValues="${!values}" # Here we expand the dynamic variable we created in the previous line. ! Does the trick
|
||||
usersArray=(${newValues//,/ }) # Split the values using comma (,) as separator.
|
||||
|
||||
if [ -n "$newValues" ]
|
||||
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' )
|
||||
# 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"
|
||||
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
|
||||
fi
|
||||
done
|
||||
fi
|
||||
set +o noglob
|
||||
|
||||
ynh_print_info "Users with role $role added in $final_path/config.yaml"
|
||||
}
|
||||
|
||||
ynh_app_config_run $1
|
||||
|
|
|
@ -52,6 +52,38 @@ bot_synapse_db_user="@$botname:$server_name"
|
|||
synapse_db_name="matrix_$synapse_instance"
|
||||
signald_user="signald" # This is actually chosen by the signald dependency
|
||||
|
||||
#=================================================
|
||||
# SET STANDARD SETTINGS FROM DEFAULT CONFIG
|
||||
#=================================================
|
||||
|
||||
appserviceid=$botname
|
||||
displayname="Signal bridge bot"
|
||||
avatar="mxc://maunium.net/wPJgTQbZOtpBFmDNkiNEMDUp"
|
||||
ephemeral_events=false
|
||||
enable_metrics=false
|
||||
metrics_listen_port=8000
|
||||
registration_enabled=true
|
||||
enable_disappearing_messages_in_groups=false
|
||||
username_template="sg_{userid}"
|
||||
contact_list_names=disallow
|
||||
federate_rooms=true
|
||||
encryption_default=false
|
||||
print_level=INFO
|
||||
|
||||
ynh_app_setting_set --app=$app --key=appserviceid --value=$appserviceid
|
||||
ynh_app_setting_set --app=$app --key=displayname --value=$displayname
|
||||
ynh_app_setting_set --app=$app --key=avatar --value=$avatar
|
||||
ynh_app_setting_set --app=$app --key=ephemeral_events --value=$ephemeral_events
|
||||
ynh_app_setting_set --app=$app --key=enable_metrics --value=$enable_metrics
|
||||
ynh_app_setting_set --app=$app --key=metrics_listen_port --value=$metrics_listen_port
|
||||
ynh_app_setting_set --app=$app --key=registration_enabled --value=$registration_enabled
|
||||
ynh_app_setting_set --app=$app --key=enable_disappearing_messages_in_groups --value=$enable_disappearing_messages_in_groups
|
||||
ynh_app_setting_set --app=$app --key=username_template --value=$username_template
|
||||
ynh_app_setting_set --app=$app --key=contact_list_names --value=$contact_list_names
|
||||
ynh_app_setting_set --app=$app --key=federate_rooms --value=$federate_rooms
|
||||
ynh_app_setting_set --app=$app --key=encryption_default --value=$encryption_default
|
||||
ynh_app_setting_set --app=$app --key=print_level --value=$print_level
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
|
|
|
@ -34,6 +34,24 @@ synapse_db_name="matrix_$synapse_instance"
|
|||
signald_user="signald" # This is actually chosen by the signald dependency
|
||||
enable_relaybot=true
|
||||
|
||||
#=================================================
|
||||
# GET CONFIG PANEL SETTINGS
|
||||
#=================================================
|
||||
appserviceid=$(ynh_app_setting_get --app=$app --key=appserviceid)
|
||||
displayname=$(ynh_app_setting_get --app=$app --key=displayname)
|
||||
avatar=$(ynh_app_setting_get --app=$avatar --key=avatar)
|
||||
ephemeral_events=$(ynh_app_setting_get --app=$app --key=ephemeral_events)
|
||||
enable_metrics=$(ynh_app_setting_get --app=$app --key=enable_metrics)
|
||||
metrics_listen_port=$(ynh_app_setting_get --app=$app --key=metrics_listen_port)
|
||||
registration_enabled=$(ynh_app_setting_get --app=$app --key=registration_enabled)
|
||||
enable_disappearing_messages_in_groups=$(ynh_app_setting_get --app=$app --key=enable_disappearing_messages_in_groups)
|
||||
username_template=$(ynh_app_setting_get --app=$app --key=username_template)
|
||||
contact_list_names=$(ynh_app_setting_get --app=$app --key=contact_list_names)
|
||||
federate_rooms=$(ynh_app_setting_get --app=$app --key=federate_rooms)
|
||||
encryption_default=$(ynh_app_setting_get --app=$app --key=encryption_default)
|
||||
print_level=$(ynh_app_setting_get --app=$app --key=print_level)
|
||||
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
@ -69,20 +87,77 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
|
|||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
|
||||
# Upgrade from >0.2.0
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||
# SET STANDARD SETTINGS FROM DEFAULT CONFIG
|
||||
|
||||
# Upgrade from <=0.2.0
|
||||
if [ -z "$db_name" ]
|
||||
if [ -z "$appserviceid" ]
|
||||
then
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=$app)
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
appserviceid=$botname
|
||||
ynh_app_setting_set --app=$app --key=appserviceid --value=$appserviceid
|
||||
fi
|
||||
if [ -z "$db_pwd" ]
|
||||
if [ -z "$displayname" ]
|
||||
then
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_pwd)
|
||||
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
|
||||
displayname="Signal bridge bot"
|
||||
ynh_app_setting_set --app=$app --key=displayname --value=$displayname
|
||||
fi
|
||||
|
||||
if [ -z "$avatar" ]
|
||||
then
|
||||
avatar="mxc://maunium.net/wPJgTQbZOtpBFmDNkiNEMDUp"
|
||||
ynh_app_setting_set --app=$app --key=avatar --value=$avatar
|
||||
fi
|
||||
|
||||
if [ -z "$enable_metrics" ]
|
||||
then
|
||||
enable_metrics=false
|
||||
ynh_app_setting_set --app=$app --key=enable_metrics --value=$enable_metrics
|
||||
fi
|
||||
|
||||
if [ -z "$metrics_listen_port" ]
|
||||
then
|
||||
metrics_listen_port=8000
|
||||
ynh_app_setting_set --app=$app --key=metrics_listen_port --value=$metrics_listen_port
|
||||
fi
|
||||
|
||||
if [ -z "$registration_enabled" ]
|
||||
then
|
||||
registration_enabled=true
|
||||
ynh_app_setting_set --app=$app --key=registration_enabled --value=$registration_enabled
|
||||
fi
|
||||
|
||||
if [ -z "$enable_disappearing_messages_in_groups" ]
|
||||
then
|
||||
enable_disappearing_messages_in_groups=false
|
||||
ynh_app_setting_set --app=$app --key=enable_disappearing_messages_in_groups --value=$enable_disappearing_messages_in_groups
|
||||
fi
|
||||
|
||||
if [ -z "$username_template" ]
|
||||
then
|
||||
username_template="sg_{userid}"
|
||||
ynh_app_setting_set --app=$app --key=username_template --value=$username_template
|
||||
fi
|
||||
|
||||
if [ -z "$contact_list_names" ]
|
||||
then
|
||||
contact_list_names=disallow
|
||||
ynh_app_setting_set --app=$app --key=contact_list_names --value=$contact_list_names
|
||||
fi
|
||||
|
||||
if [ -z "$federate_rooms" ]
|
||||
then
|
||||
federate_rooms=true
|
||||
ynh_app_setting_set --app=$app --key=federate_rooms --value=$federate_rooms
|
||||
fi
|
||||
|
||||
if [ -z "$encryption_default" ]
|
||||
then
|
||||
encryption_default=false
|
||||
ynh_app_setting_set --app=$app --key=encryption_default --value=$encryption_default
|
||||
fi
|
||||
|
||||
if [ -z "$print_level" ]
|
||||
then
|
||||
print_level=INFO
|
||||
ynh_app_setting_set --app=$app --key=print_level --value=$print_level
|
||||
fi
|
||||
|
||||
# Fix possible permission issues with a previous signald version, esp. with stickers
|
||||
|
|
Loading…
Reference in a new issue