diff --git a/conf/config.yaml b/conf/config.yaml index 666cdd7..ddb437d 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -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] diff --git a/config_panel.toml b/config_panel.toml index 45968a0..1e101ff 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -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" \ No newline at end of file + 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"] diff --git a/scripts/config b/scripts/config index 45faa2f..a2bf348 100644 --- a/scripts/config +++ b/scripts/config @@ -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 <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