Skip to content

Commit

Permalink
Add Plex account map to sessions endpoint. (#69)
Browse files Browse the repository at this point in the history
* add plex map
  • Loading branch information
davidnewhall authored May 18, 2021
1 parent e488f78 commit 1a3891b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pkg/plex/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package plex
import (
"fmt"
"net/http"
"strings"

"github.com/Notifiarr/notifiarr/pkg/apps"
"github.com/gorilla/mux"
Expand All @@ -20,7 +21,11 @@ func (s *Server) HandleSessions(r *http.Request) (int, interface{}) {
return http.StatusInternalServerError, fmt.Errorf("unable to get sessions (%d): %w", plexID, err)
}

return http.StatusOK, sessions
return http.StatusOK, &Sessions{
Name: s.Name,
AccountMap: strings.Split(s.AccountMap, "|"),
Sessions: sessions,
}
}

func (s *Server) HandleKillSession(r *http.Request) (int, interface{}) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/plex/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Sessions struct {
Name string `json:"server"`
AccountMap []string `json:"account_map"`
Sessions []*Session `json:"sessions"`
XML string `json:"sessions_xml"`
XML string `json:"sessions_xml,omitempty"`
}

var ErrBadStatus = fmt.Errorf("status code not 200")
Expand Down

0 comments on commit 1a3891b

Please sign in to comment.