Skip to content

Commit

Permalink
Return early for 204 No Content
Browse files Browse the repository at this point in the history
Signed-off-by: Marcus Crane <marcus@utf9k.net>
  • Loading branch information
marcus-crane committed Nov 26, 2023
1 parent 3c5bfe7 commit f0c5e20
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions jobs/trakt.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ func GetCurrentlyPlayingTrakt(store db.Store, client http.Client) {
return
}

// Nothing is playing so we should check if anything needs to be cleaned up
// or if we need to do a state transition
if res.StatusCode == 204 {
if CurrentPlaybackItem.IsActive && CurrentPlaybackItem.Source == "trakt" {
CurrentPlaybackItem.IsActive = false
byteStream := new(bytes.Buffer)
json.NewEncoder(byteStream).Encode(CurrentPlaybackItem)
events.Server.Publish("playback", &sse.Event{Data: byteStream.Bytes()})
}
return
}

body, err := io.ReadAll(res2.Body)
if err != nil {
slog.Error("Failed to unmarshal Trakt response",
Expand Down

0 comments on commit f0c5e20

Please sign in to comment.