Skip to content

Commit

Permalink
fix: allow requests for notification event details
Browse files Browse the repository at this point in the history
  • Loading branch information
remoterami committed Jan 8, 2025
1 parent 12864ad commit 4e33da4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/pkg/api/handlers/middlewares.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (h *HandlerService) VDBArchivedCheckMiddleware(next http.Handler) http.Hand
return
}
if dashboard.IsArchived {
handleErr(w, r, newForbiddenErr("dashboard with id %v is archived", dashboardId))
handleErr(w, r, newForbiddenErr("dashboard with id %s is archived", mux.Vars(r)["dashboard_id"]))
return
}
next.ServeHTTP(w, r)
Expand Down
15 changes: 13 additions & 2 deletions backend/pkg/api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,18 +353,29 @@ func addNotificationRoutes(hs *handlers.HandlerService, publicRouter, internalRo

publicDashboardNotificationSettingsRouter := publicNotificationRouter.NewRoute().Subrouter()
internalDashboardNotificationSettingsRouter := internalNotificationRouter.NewRoute().Subrouter()
// TODO add adb auth and archivedCheck middleware to account dashboard endpoints once they are implemented
// TODO add adb auth middleware to account dashboard endpoints once they are implemented
if !debug {
publicDashboardNotificationSettingsRouter.Use(hs.VDBAuthMiddleware, hs.VDBArchivedCheckMiddleware)
internalDashboardNotificationSettingsRouter.Use(hs.VDBAuthMiddleware, hs.VDBArchivedCheckMiddleware)
}
dashboardSettingsEndpoints := []endpoint{
{http.MethodGet, "/validator-dashboards/{dashboard_id}/groups/{group_id}/epochs/{epoch}", hs.PublicGetUserNotificationsValidatorDashboard, hs.InternalGetUserNotificationsValidatorDashboard},
{http.MethodGet, "/account-dashboards/{dashboard_id}/groups/{group_id}/epochs/{epoch}", hs.PublicGetUserNotificationsAccountDashboard, hs.InternalGetUserNotificationsAccountDashboard},
}
addEndpointsToRouters(dashboardSettingsEndpoints, publicDashboardNotificationSettingsRouter, internalDashboardNotificationSettingsRouter)

publicActiveDashboardNotificationSettingsRouter := publicDashboardNotificationSettingsRouter.NewRoute().Subrouter()
internalActiveDashboardNotificationSettingsRouter := internalDashboardNotificationSettingsRouter.NewRoute().Subrouter()
// TODO add archivedCheck middleware to account dashboard endpoints once they are implemented
if !debug {
publicActiveDashboardNotificationSettingsRouter.Use(hs.VDBArchivedCheckMiddleware)
internalActiveDashboardNotificationSettingsRouter.Use(hs.VDBArchivedCheckMiddleware)
}
activeDashboardSettingsEndpoints := []endpoint{
{http.MethodPut, "/settings/validator-dashboards/{dashboard_id}/groups/{group_id}", hs.PublicPutUserNotificationSettingsValidatorDashboard, hs.InternalPutUserNotificationSettingsValidatorDashboard},
{http.MethodPut, "/settings/account-dashboards/{dashboard_id}/groups/{group_id}", hs.PublicPutUserNotificationSettingsAccountDashboard, hs.InternalPutUserNotificationSettingsAccountDashboard},
}
addEndpointsToRouters(dashboardSettingsEndpoints, publicDashboardNotificationSettingsRouter, internalDashboardNotificationSettingsRouter)
addEndpointsToRouters(activeDashboardSettingsEndpoints, publicActiveDashboardNotificationSettingsRouter, internalActiveDashboardNotificationSettingsRouter)
}

func addEndpointsToRouters(endpoints []endpoint, publicRouter *mux.Router, internalRouter *mux.Router) {
Expand Down

0 comments on commit 4e33da4

Please sign in to comment.