diff --git a/appservice/appservice.go b/appservice/appservice.go index f4d74672..f2ef6f37 100644 --- a/appservice/appservice.go +++ b/appservice/appservice.go @@ -46,6 +46,8 @@ func Create() *AppService { StateStore: NewBasicStateStore(), Router: mux.NewRouter(), UserAgent: mautrix.DefaultUserAgent, + Live: true, + Ready: false, } } @@ -105,6 +107,9 @@ type AppService struct { DefaultHTTPRetries int + Live bool + Ready bool + clients map[id.UserID]*mautrix.Client clientsLock sync.RWMutex intents map[id.UserID]*IntentAPI diff --git a/appservice/http.go b/appservice/http.go index ce4387c6..4faf32a9 100644 --- a/appservice/http.go +++ b/appservice/http.go @@ -30,6 +30,8 @@ func (as *AppService) Start() { as.Router.HandleFunc("/_matrix/app/v1/transactions/{txnID}", as.PutTransaction).Methods(http.MethodPut) as.Router.HandleFunc("/_matrix/app/v1/rooms/{roomAlias}", as.GetRoom).Methods(http.MethodGet) as.Router.HandleFunc("/_matrix/app/v1/users/{userID}", as.GetUser).Methods(http.MethodGet) + as.Router.HandleFunc("/_matrix/mau/live", as.GetLive).Methods(http.MethodGet) + as.Router.HandleFunc("/_matrix/mau/ready", as.GetReady).Methods(http.MethodGet) var err error as.server = &http.Server{ @@ -237,3 +239,23 @@ func (as *AppService) GetUser(w http.ResponseWriter, r *http.Request) { }.Write(w) } } + +func (as *AppService) GetLive(w http.ResponseWriter, r *http.Request) { + w.Header().Add("Content-Type", "application/json") + if as.Live { + w.WriteHeader(http.StatusOK) + } else { + w.WriteHeader(http.StatusInternalServerError) + } + w.Write([]byte("{}")) +} + +func (as *AppService) GetReady(w http.ResponseWriter, r *http.Request) { + w.Header().Add("Content-Type", "application/json") + if as.Ready { + w.WriteHeader(http.StatusOK) + } else { + w.WriteHeader(http.StatusInternalServerError) + } + w.Write([]byte("{}")) +}