forked from MirrorHub/mautrix-whatsapp
Move provisioning endpoint version into code
This commit is contained in:
parent
8da6e14bf8
commit
082bdcca11
3 changed files with 19 additions and 14 deletions
|
@ -20,6 +20,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
|
@ -42,7 +43,11 @@ func (helper *UpgradeHelper) doUpgrade() {
|
|||
helper.Copy(Int, "appservice", "database", "max_idle_conns")
|
||||
helper.Copy(Str|Null, "appservice", "database", "max_conn_idle_time")
|
||||
helper.Copy(Str|Null, "appservice", "database", "max_conn_lifetime")
|
||||
helper.Copy(Str, "appservice", "provisioning", "prefix")
|
||||
if prefix, ok := helper.Get(Str, "appservice", "provisioning", "prefix"); ok && strings.HasSuffix(prefix, "/v1") {
|
||||
helper.Set(Str, strings.TrimSuffix(prefix, "/v1"), "appservice", "provisioning", "prefix")
|
||||
} else {
|
||||
helper.Copy(Str, "appservice", "provisioning", "prefix")
|
||||
}
|
||||
if secret, ok := helper.Get(Str, "appservice", "provisioning", "shared_secret"); !ok || secret == "generate" {
|
||||
sharedSecret := appservice.RandomString(64)
|
||||
helper.Set(Str, sharedSecret, "appservice", "provisioning", "shared_secret")
|
||||
|
|
|
@ -44,7 +44,7 @@ appservice:
|
|||
# Settings for provisioning API
|
||||
provisioning:
|
||||
# Prefix for the provisioning API paths.
|
||||
prefix: /_matrix/provision/v1
|
||||
prefix: /_matrix/provision
|
||||
# Shared secret for authentication. If set to "generate", a random secret will be generated,
|
||||
# or if set to "disable", the provisioning API will be disabled.
|
||||
shared_secret: generate
|
||||
|
|
|
@ -50,22 +50,22 @@ func (prov *ProvisioningAPI) Init() {
|
|||
prov.log.Debugln("Enabling provisioning API at", prov.bridge.Config.AppService.Provisioning.Prefix)
|
||||
r := prov.bridge.AS.Router.PathPrefix(prov.bridge.Config.AppService.Provisioning.Prefix).Subrouter()
|
||||
r.Use(prov.AuthMiddleware)
|
||||
r.HandleFunc("/ping", prov.Ping).Methods(http.MethodGet)
|
||||
r.HandleFunc("/login", prov.Login).Methods(http.MethodGet)
|
||||
r.HandleFunc("/logout", prov.Logout).Methods(http.MethodPost)
|
||||
r.HandleFunc("/delete_session", prov.DeleteSession).Methods(http.MethodPost)
|
||||
r.HandleFunc("/disconnect", prov.Disconnect).Methods(http.MethodPost)
|
||||
r.HandleFunc("/reconnect", prov.Reconnect).Methods(http.MethodPost)
|
||||
r.HandleFunc("/sync/appstate/{name}", prov.SyncAppState).Methods(http.MethodPost)
|
||||
r.HandleFunc("/contacts", prov.ListContacts).Methods(http.MethodGet)
|
||||
r.HandleFunc("/groups", prov.ListGroups).Methods(http.MethodGet)
|
||||
r.HandleFunc("/pm/{number}", prov.StartPM).Methods(http.MethodPost)
|
||||
r.HandleFunc("/open/{groupID}", prov.OpenGroup).Methods(http.MethodPost)
|
||||
r.HandleFunc("/v1/ping", prov.Ping).Methods(http.MethodGet)
|
||||
r.HandleFunc("/v1/login", prov.Login).Methods(http.MethodGet)
|
||||
r.HandleFunc("/v1/logout", prov.Logout).Methods(http.MethodPost)
|
||||
r.HandleFunc("/v1/delete_session", prov.DeleteSession).Methods(http.MethodPost)
|
||||
r.HandleFunc("/v1/disconnect", prov.Disconnect).Methods(http.MethodPost)
|
||||
r.HandleFunc("/v1/reconnect", prov.Reconnect).Methods(http.MethodPost)
|
||||
r.HandleFunc("/v1/sync/appstate/{name}", prov.SyncAppState).Methods(http.MethodPost)
|
||||
r.HandleFunc("/v1/contacts", prov.ListContacts).Methods(http.MethodGet)
|
||||
r.HandleFunc("/v1/groups", prov.ListGroups).Methods(http.MethodGet)
|
||||
r.HandleFunc("/v1/pm/{number}", prov.StartPM).Methods(http.MethodPost)
|
||||
r.HandleFunc("/v1/open/{groupID}", prov.OpenGroup).Methods(http.MethodPost)
|
||||
prov.bridge.AS.Router.HandleFunc("/_matrix/app/com.beeper.asmux/ping", prov.BridgeStatePing).Methods(http.MethodPost)
|
||||
prov.bridge.AS.Router.HandleFunc("/_matrix/app/com.beeper.bridge_state", prov.BridgeStatePing).Methods(http.MethodPost)
|
||||
|
||||
// Deprecated, just use /disconnect
|
||||
r.HandleFunc("/delete_connection", prov.Disconnect).Methods(http.MethodPost)
|
||||
r.HandleFunc("/v1/delete_connection", prov.Disconnect).Methods(http.MethodPost)
|
||||
}
|
||||
|
||||
type responseWrap struct {
|
||||
|
|
Loading…
Reference in a new issue