diff --git a/internal/api/router.go b/internal/api/router.go index 3cf1d218..dbe877a9 100644 --- a/internal/api/router.go +++ b/internal/api/router.go @@ -45,6 +45,7 @@ func (api *ApiManagerCtx) Route(r types.Router) { r.Post("/logout", api.Logout) r.Get("/whoami", api.Whoami) + r.Get("/sessions", api.Sessions) membersHandler := members.New(api.members) r.Route("/members", membersHandler.Route) diff --git a/internal/api/session.go b/internal/api/session.go index e221d1d6..e1991ad6 100644 --- a/internal/api/session.go +++ b/internal/api/session.go @@ -81,3 +81,16 @@ func (api *ApiManagerCtx) Whoami(w http.ResponseWriter, r *http.Request) error { State: session.State(), }) } + +func (api *ApiManagerCtx) Sessions(w http.ResponseWriter, r *http.Request) error { + sessions := []SessionDataPayload{} + for _, session := range api.sessions.List() { + sessions = append(sessions, SessionDataPayload{ + ID: session.ID(), + Profile: session.Profile(), + State: session.State(), + }) + } + + return utils.HttpSuccess(w, sessions) +} diff --git a/openapi.yaml b/openapi.yaml index af4f5af9..db9fa981 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -116,6 +116,25 @@ paths: $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' + /api/sessions: + get: + tags: + - session + summary: get sessions + operationId: sessionsGet + responses: + '200': + description: OK + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/SessionData' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' # # room