From eab0135fea595cce83c60e2dc369667096549899 Mon Sep 17 00:00:00 2001 From: Matt Poegel Date: Mon, 13 May 2024 00:23:21 +0000 Subject: [PATCH] fix api nil reference error --- go.mod | 2 +- pkg/pizza/server_api.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 8b6bc37..c88991f 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/Nerzal/gocloak/v13 v13.9.0 github.com/coreos/go-oidc v2.2.1+incompatible github.com/golang-jwt/jwt/v5 v5.0.0 + github.com/google/jsonapi v1.0.0 github.com/google/uuid v1.3.0 github.com/gorilla/mux v1.8.0 github.com/mattn/go-sqlite3 v1.14.19 @@ -26,7 +27,6 @@ require ( github.com/go-resty/resty/v2 v2.7.0 // indirect github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/google/jsonapi v1.0.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.1 // indirect github.com/googleapis/gax-go/v2 v2.7.0 // indirect github.com/kr/text v0.2.0 // indirect diff --git a/pkg/pizza/server_api.go b/pkg/pizza/server_api.go index 1dcb4e1..95eacbf 100644 --- a/pkg/pizza/server_api.go +++ b/pkg/pizza/server_api.go @@ -125,10 +125,13 @@ func (s *Server) HandleAPIGetFriday(token *jwt.Token, claims *TokenClaims, w htt friday := &api.Friday{ ID: id, StartTime: f.Date, - Details: *f.Details, Guests: nil, } + if f.Details != nil { + friday.Details = *f.Details + } + // not part of invited group if f.Group != nil && !claims.InGroup(*f.Group) { // if this friday was specifically requested, the response needs to be 404