2022-05-22 19:16:42 +00:00
|
|
|
// mautrix-discord - A Matrix-Discord puppeting bridge.
|
2023-04-14 10:39:22 +00:00
|
|
|
// Copyright (C) 2023 Tulir Asokan
|
2022-05-22 19:16:42 +00:00
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
2023-08-16 21:54:38 +00:00
|
|
|
up "go.mau.fi/util/configupgrade"
|
|
|
|
"go.mau.fi/util/random"
|
2022-05-22 19:16:42 +00:00
|
|
|
"maunium.net/go/mautrix/bridge/bridgeconfig"
|
2024-02-18 21:10:19 +00:00
|
|
|
"maunium.net/go/mautrix/federation"
|
2022-05-22 19:16:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func DoUpgrade(helper *up.Helper) {
|
|
|
|
bridgeconfig.Upgrader.DoUpgrade(helper)
|
|
|
|
|
|
|
|
helper.Copy(up.Str, "bridge", "username_template")
|
|
|
|
helper.Copy(up.Str, "bridge", "displayname_template")
|
2022-07-08 17:48:36 +00:00
|
|
|
helper.Copy(up.Str, "bridge", "channel_name_template")
|
|
|
|
helper.Copy(up.Str, "bridge", "guild_name_template")
|
2023-04-14 10:39:22 +00:00
|
|
|
if legacyPrivateChatPortalMeta, ok := helper.Get(up.Bool, "bridge", "private_chat_portal_meta"); ok {
|
|
|
|
updatedPrivateChatPortalMeta := "default"
|
|
|
|
if legacyPrivateChatPortalMeta == "true" {
|
|
|
|
updatedPrivateChatPortalMeta = "always"
|
|
|
|
}
|
|
|
|
helper.Set(up.Str, updatedPrivateChatPortalMeta, "bridge", "private_chat_portal_meta")
|
|
|
|
} else {
|
|
|
|
helper.Copy(up.Str, "bridge", "private_chat_portal_meta")
|
|
|
|
}
|
2022-07-08 19:46:33 +00:00
|
|
|
helper.Copy(up.Int, "bridge", "startup_private_channel_create_limit")
|
2024-07-12 17:09:07 +00:00
|
|
|
helper.Copy(up.Str|up.Null, "bridge", "public_address")
|
|
|
|
if apkey, ok := helper.Get(up.Str, "bridge", "avatar_proxy_key"); !ok || apkey == "generate" {
|
|
|
|
helper.Set(up.Str, random.String(32), "bridge", "avatar_proxy_key")
|
|
|
|
} else {
|
|
|
|
helper.Copy(up.Str, "bridge", "avatar_proxy_key")
|
|
|
|
}
|
2022-05-22 19:16:42 +00:00
|
|
|
helper.Copy(up.Int, "bridge", "portal_message_buffer")
|
2022-05-30 12:58:03 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "delivery_receipts")
|
2022-06-27 08:14:29 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "message_status_events")
|
|
|
|
helper.Copy(up.Bool, "bridge", "message_error_notices")
|
2022-05-30 12:59:26 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "restricted_rooms")
|
2022-10-28 20:35:31 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "autojoin_thread_on_open")
|
2023-01-28 01:16:33 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "embed_fields_as_tables")
|
2023-01-20 13:07:18 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "mute_channels_on_create")
|
2022-05-22 19:16:42 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "sync_direct_chat_list")
|
2022-06-27 08:48:51 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "resend_bridge_info")
|
2023-01-27 19:23:10 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "custom_emoji_reactions")
|
2022-07-09 13:51:43 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "delete_portal_on_channel_delete")
|
2023-01-27 19:06:29 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "delete_guild_on_leave")
|
2022-05-27 12:58:09 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "federate_rooms")
|
2023-05-27 10:01:24 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "prefix_webhook_messages")
|
|
|
|
helper.Copy(up.Bool, "bridge", "enable_webhook_avatars")
|
2023-05-14 11:46:04 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "use_discord_cdn_upload")
|
2023-05-05 09:50:55 +00:00
|
|
|
helper.Copy(up.Str, "bridge", "cache_media")
|
2024-02-18 21:10:19 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "direct_media", "enabled")
|
|
|
|
helper.Copy(up.Str, "bridge", "direct_media", "server_name")
|
|
|
|
helper.Copy(up.Str|up.Null, "bridge", "direct_media", "well_known_response")
|
|
|
|
helper.Copy(up.Bool, "bridge", "direct_media", "allow_proxy")
|
|
|
|
if serverKey, ok := helper.Get(up.Str, "bridge", "direct_media", "server_key"); !ok || serverKey == "generate" {
|
|
|
|
serverKey = federation.GenerateSigningKey().SynapseString()
|
|
|
|
helper.Set(up.Str, serverKey, "bridge", "direct_media", "server_key")
|
|
|
|
} else {
|
|
|
|
helper.Copy(up.Str, "bridge", "direct_media", "server_key")
|
|
|
|
}
|
2023-02-04 14:10:03 +00:00
|
|
|
helper.Copy(up.Str, "bridge", "animated_sticker", "target")
|
|
|
|
helper.Copy(up.Int, "bridge", "animated_sticker", "args", "width")
|
|
|
|
helper.Copy(up.Int, "bridge", "animated_sticker", "args", "height")
|
|
|
|
helper.Copy(up.Int, "bridge", "animated_sticker", "args", "fps")
|
2022-05-22 19:16:42 +00:00
|
|
|
helper.Copy(up.Map, "bridge", "double_puppet_server_map")
|
|
|
|
helper.Copy(up.Bool, "bridge", "double_puppet_allow_discovery")
|
|
|
|
helper.Copy(up.Map, "bridge", "login_shared_secret_map")
|
|
|
|
helper.Copy(up.Str, "bridge", "command_prefix")
|
|
|
|
helper.Copy(up.Str, "bridge", "management_room_text", "welcome")
|
|
|
|
helper.Copy(up.Str, "bridge", "management_room_text", "welcome_connected")
|
|
|
|
helper.Copy(up.Str, "bridge", "management_room_text", "welcome_unconnected")
|
|
|
|
helper.Copy(up.Str|up.Null, "bridge", "management_room_text", "additional_help")
|
2023-04-16 12:06:02 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "backfill", "enabled")
|
2023-04-16 12:35:29 +00:00
|
|
|
helper.Copy(up.Int, "bridge", "backfill", "forward_limits", "initial", "dm")
|
|
|
|
helper.Copy(up.Int, "bridge", "backfill", "forward_limits", "initial", "channel")
|
2023-06-18 17:09:21 +00:00
|
|
|
helper.Copy(up.Int, "bridge", "backfill", "forward_limits", "initial", "thread")
|
2023-04-16 12:35:29 +00:00
|
|
|
helper.Copy(up.Int, "bridge", "backfill", "forward_limits", "missed", "dm")
|
|
|
|
helper.Copy(up.Int, "bridge", "backfill", "forward_limits", "missed", "channel")
|
2023-06-18 17:09:21 +00:00
|
|
|
helper.Copy(up.Int, "bridge", "backfill", "forward_limits", "missed", "thread")
|
2023-04-16 20:11:44 +00:00
|
|
|
helper.Copy(up.Int, "bridge", "backfill", "max_guild_members")
|
2022-05-22 19:16:42 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "encryption", "allow")
|
|
|
|
helper.Copy(up.Bool, "bridge", "encryption", "default")
|
2022-06-27 08:14:29 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "encryption", "require")
|
2022-09-14 18:13:39 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "encryption", "appservice")
|
2022-06-27 08:14:29 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "encryption", "allow_key_sharing")
|
2023-05-24 10:18:23 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "encryption", "plaintext_mentions")
|
2023-04-13 14:08:52 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "encryption", "delete_keys", "delete_outbound_on_ack")
|
|
|
|
helper.Copy(up.Bool, "bridge", "encryption", "delete_keys", "dont_store_outbound")
|
|
|
|
helper.Copy(up.Bool, "bridge", "encryption", "delete_keys", "ratchet_on_decrypt")
|
|
|
|
helper.Copy(up.Bool, "bridge", "encryption", "delete_keys", "delete_fully_used_on_decrypt")
|
|
|
|
helper.Copy(up.Bool, "bridge", "encryption", "delete_keys", "delete_prev_on_new_session")
|
|
|
|
helper.Copy(up.Bool, "bridge", "encryption", "delete_keys", "delete_on_device_delete")
|
|
|
|
helper.Copy(up.Bool, "bridge", "encryption", "delete_keys", "periodically_delete_expired")
|
2023-06-23 12:20:11 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "encryption", "delete_keys", "delete_outdated_inbound")
|
2022-06-27 08:14:29 +00:00
|
|
|
helper.Copy(up.Str, "bridge", "encryption", "verification_levels", "receive")
|
|
|
|
helper.Copy(up.Str, "bridge", "encryption", "verification_levels", "send")
|
|
|
|
helper.Copy(up.Str, "bridge", "encryption", "verification_levels", "share")
|
2022-06-22 13:56:13 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "encryption", "rotation", "enable_custom")
|
|
|
|
helper.Copy(up.Int, "bridge", "encryption", "rotation", "milliseconds")
|
|
|
|
helper.Copy(up.Int, "bridge", "encryption", "rotation", "messages")
|
2023-06-06 10:52:43 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "encryption", "rotation", "disable_device_change_key_rotation")
|
2022-05-22 19:16:42 +00:00
|
|
|
|
|
|
|
helper.Copy(up.Str, "bridge", "provisioning", "prefix")
|
|
|
|
if secret, ok := helper.Get(up.Str, "bridge", "provisioning", "shared_secret"); !ok || secret == "generate" {
|
2023-08-16 21:54:38 +00:00
|
|
|
sharedSecret := random.String(64)
|
2022-05-22 19:16:42 +00:00
|
|
|
helper.Set(up.Str, sharedSecret, "bridge", "provisioning", "shared_secret")
|
|
|
|
} else {
|
|
|
|
helper.Copy(up.Str, "bridge", "provisioning", "shared_secret")
|
|
|
|
}
|
2023-12-05 10:09:11 +00:00
|
|
|
helper.Copy(up.Bool, "bridge", "provisioning", "debug_endpoints")
|
2022-05-22 19:16:42 +00:00
|
|
|
|
|
|
|
helper.Copy(up.Map, "bridge", "permissions")
|
|
|
|
//helper.Copy(up.Bool, "bridge", "relay", "enabled")
|
|
|
|
//helper.Copy(up.Bool, "bridge", "relay", "admin_only")
|
|
|
|
//helper.Copy(up.Map, "bridge", "relay", "message_formats")
|
|
|
|
}
|
|
|
|
|
|
|
|
var SpacedBlocks = [][]string{
|
2022-09-13 11:44:31 +00:00
|
|
|
{"homeserver", "software"},
|
2022-05-22 19:16:42 +00:00
|
|
|
{"appservice"},
|
|
|
|
{"appservice", "hostname"},
|
|
|
|
{"appservice", "database"},
|
|
|
|
{"appservice", "id"},
|
|
|
|
{"appservice", "as_token"},
|
|
|
|
{"bridge"},
|
|
|
|
{"bridge", "command_prefix"},
|
|
|
|
{"bridge", "management_room_text"},
|
|
|
|
{"bridge", "encryption"},
|
|
|
|
{"bridge", "provisioning"},
|
|
|
|
{"bridge", "permissions"},
|
|
|
|
//{"bridge", "relay"},
|
|
|
|
{"logging"},
|
|
|
|
}
|