upgrade.go 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // mautrix-discord - A Matrix-Discord puppeting bridge.
  2. // Copyright (C) 2022 Tulir Asokan
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Affero General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Affero General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Affero General Public License
  15. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. package config
  17. import (
  18. "maunium.net/go/mautrix/appservice"
  19. "maunium.net/go/mautrix/bridge/bridgeconfig"
  20. up "maunium.net/go/mautrix/util/configupgrade"
  21. )
  22. func DoUpgrade(helper *up.Helper) {
  23. bridgeconfig.Upgrader.DoUpgrade(helper)
  24. helper.Copy(up.Str, "bridge", "username_template")
  25. helper.Copy(up.Str, "bridge", "displayname_template")
  26. helper.Copy(up.Str, "bridge", "channelname_template")
  27. helper.Copy(up.Int, "bridge", "portal_message_buffer")
  28. helper.Copy(up.Bool, "bridge", "delivery_receipts")
  29. helper.Copy(up.Bool, "bridge", "restricted_rooms")
  30. helper.Copy(up.Bool, "bridge", "sync_with_custom_puppets")
  31. helper.Copy(up.Bool, "bridge", "sync_direct_chat_list")
  32. helper.Copy(up.Bool, "bridge", "federate_rooms")
  33. helper.Copy(up.Map, "bridge", "double_puppet_server_map")
  34. helper.Copy(up.Bool, "bridge", "double_puppet_allow_discovery")
  35. helper.Copy(up.Map, "bridge", "login_shared_secret_map")
  36. helper.Copy(up.Str, "bridge", "command_prefix")
  37. helper.Copy(up.Str, "bridge", "management_room_text", "welcome")
  38. helper.Copy(up.Str, "bridge", "management_room_text", "welcome_connected")
  39. helper.Copy(up.Str, "bridge", "management_room_text", "welcome_unconnected")
  40. helper.Copy(up.Str|up.Null, "bridge", "management_room_text", "additional_help")
  41. helper.Copy(up.Bool, "bridge", "encryption", "allow")
  42. helper.Copy(up.Bool, "bridge", "encryption", "default")
  43. helper.Copy(up.Bool, "bridge", "encryption", "key_sharing", "allow")
  44. helper.Copy(up.Bool, "bridge", "encryption", "key_sharing", "require_cross_signing")
  45. helper.Copy(up.Bool, "bridge", "encryption", "key_sharing", "require_verification")
  46. helper.Copy(up.Str, "bridge", "provisioning", "prefix")
  47. if secret, ok := helper.Get(up.Str, "bridge", "provisioning", "shared_secret"); !ok || secret == "generate" {
  48. sharedSecret := appservice.RandomString(64)
  49. helper.Set(up.Str, sharedSecret, "bridge", "provisioning", "shared_secret")
  50. } else {
  51. helper.Copy(up.Str, "bridge", "provisioning", "shared_secret")
  52. }
  53. helper.Copy(up.Map, "bridge", "permissions")
  54. //helper.Copy(up.Bool, "bridge", "relay", "enabled")
  55. //helper.Copy(up.Bool, "bridge", "relay", "admin_only")
  56. //helper.Copy(up.Map, "bridge", "relay", "message_formats")
  57. }
  58. var SpacedBlocks = [][]string{
  59. {"homeserver", "asmux"},
  60. {"appservice"},
  61. {"appservice", "hostname"},
  62. {"appservice", "database"},
  63. {"appservice", "id"},
  64. {"appservice", "as_token"},
  65. {"bridge"},
  66. {"bridge", "command_prefix"},
  67. {"bridge", "management_room_text"},
  68. {"bridge", "encryption"},
  69. {"bridge", "provisioning"},
  70. {"bridge", "permissions"},
  71. //{"bridge", "relay"},
  72. {"logging"},
  73. }