fix: error handling, defer cleanup, graceful shutdown, golangci-lint setup
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
func (s *Server) ListNotifications(w http.ResponseWriter, r *http.Request, params api.ListNotificationsParams) {
|
||||
ctx := r.Context()
|
||||
claims, ok := ctx.Value("user").(*Claims)
|
||||
claims, ok := ctx.Value(UserKey).(*Claims)
|
||||
if !ok {
|
||||
slog.ErrorContext(ctx, "Error while casting claims")
|
||||
s.JSON(w, r, http.StatusInternalServerError, MsgInternalError, RespError)
|
||||
@@ -36,7 +36,7 @@ func (s *Server) ListNotifications(w http.ResponseWriter, r *http.Request, param
|
||||
|
||||
func (s *Server) MarkNotificationRead(w http.ResponseWriter, r *http.Request, id openapi_types.UUID) {
|
||||
ctx := r.Context()
|
||||
claims, ok := ctx.Value("user").(*Claims)
|
||||
claims, ok := ctx.Value(UserKey).(*Claims)
|
||||
if !ok {
|
||||
slog.ErrorContext(ctx, "Error while casting claims")
|
||||
s.JSON(w, r, http.StatusInternalServerError, MsgInternalError, RespError)
|
||||
@@ -51,6 +51,10 @@ func (s *Server) MarkNotificationRead(w http.ResponseWriter, r *http.Request, id
|
||||
s.JSON(w, r, http.StatusInternalServerError, MsgInternalError, RespError)
|
||||
return
|
||||
}
|
||||
if notification == nil {
|
||||
s.JSON(w, r, http.StatusNotFound, MsgNotFound, RespNotFound)
|
||||
return
|
||||
}
|
||||
if notification.UserID != claims.ID {
|
||||
s.JSON(w, r, http.StatusForbidden, MsgForbidden, RespError)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user