Skip to content

Commit

Permalink
fix(api,ssh,pkg): update session type when data piped
Browse files Browse the repository at this point in the history
  • Loading branch information
henrybarreto committed Jun 5, 2024
1 parent 468c433 commit 11f6fd6
Show file tree
Hide file tree
Showing 15 changed files with 269 additions and 786 deletions.
2 changes: 1 addition & 1 deletion api/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewRouter(service services.Service) *echo.Echo {
internalAPI.POST(OfflineDeviceURL, gateway.Handler(handler.OfflineDevice))
internalAPI.GET(LookupDeviceURL, gateway.Handler(handler.LookupDevice))

internalAPI.PATCH(SetSessionAuthenticatedURL, gateway.Handler(handler.SetSessionAuthenticated))
internalAPI.PATCH(UpdateSessionURL, gateway.Handler(handler.UpdateSession))
internalAPI.POST(CreateSessionURL, gateway.Handler(handler.CreateSession))
internalAPI.POST(FinishSessionURL, gateway.Handler(handler.FinishSession))
internalAPI.POST(KeepAliveSessionURL, gateway.Handler(handler.KeepAliveSession))
Expand Down
25 changes: 14 additions & 11 deletions api/routes/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import (
)

const (
GetSessionsURL = "/sessions"
GetSessionURL = "/sessions/:uid"
SetSessionAuthenticatedURL = "/sessions/:uid"
CreateSessionURL = "/sessions"
FinishSessionURL = "/sessions/:uid/finish"
KeepAliveSessionURL = "/sessions/:uid/keepalive"
RecordSessionURL = "/sessions/:uid/record"
PlaySessionURL = "/sessions/:uid/play"
GetSessionsURL = "/sessions"
GetSessionURL = "/sessions/:uid"
UpdateSessionURL = "/sessions/:uid"
CreateSessionURL = "/sessions"
FinishSessionURL = "/sessions/:uid/finish"
KeepAliveSessionURL = "/sessions/:uid/keepalive"
RecordSessionURL = "/sessions/:uid/record"
PlaySessionURL = "/sessions/:uid/play"
)

const (
Expand Down Expand Up @@ -62,8 +62,8 @@ func (h *Handler) GetSession(c gateway.Context) error {
return c.JSON(http.StatusOK, session)
}

func (h *Handler) SetSessionAuthenticated(c gateway.Context) error {
var req requests.SessionAuthenticatedSet
func (h *Handler) UpdateSession(c gateway.Context) error {
var req requests.SessionUpdate
if err := c.Bind(&req); err != nil {
return err
}
Expand All @@ -72,7 +72,10 @@ func (h *Handler) SetSessionAuthenticated(c gateway.Context) error {
return err
}

return h.service.SetSessionAuthenticated(c.Ctx(), models.UID(req.UID), req.Authenticated)
return h.service.UpdateSession(c.Ctx(), models.UID(req.UID), models.SessionUpdate{
Authenticated: req.Authenticated,
Type: req.Type,
})
}

func (h *Handler) CreateSession(c gateway.Context) error {
Expand Down
Loading

0 comments on commit 11f6fd6

Please sign in to comment.