Skip to content

Commit 4976a1d

Browse files
committed
fix: allow requests for notification event details
1 parent c7b1b69 commit 4976a1d

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

backend/pkg/api/handlers/middlewares.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (h *HandlerService) VDBArchivedCheckMiddleware(next http.Handler) http.Hand
156156
return
157157
}
158158
if dashboard.IsArchived {
159-
handleErr(w, r, newForbiddenErr("dashboard with id %v is archived", dashboardId))
159+
handleErr(w, r, newForbiddenErr("dashboard with id %s is archived", mux.Vars(r)["dashboard_id"]))
160160
return
161161
}
162162
next.ServeHTTP(w, r)

backend/pkg/api/router.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,18 +354,29 @@ func addNotificationRoutes(hs *handlers.HandlerService, publicRouter, internalRo
354354

355355
publicDashboardNotificationSettingsRouter := publicNotificationRouter.NewRoute().Subrouter()
356356
internalDashboardNotificationSettingsRouter := internalNotificationRouter.NewRoute().Subrouter()
357-
// TODO add adb auth and archivedCheck middleware to account dashboard endpoints once they are implemented
357+
// TODO add adb auth middleware to account dashboard endpoints once they are implemented
358358
if !debug {
359359
publicDashboardNotificationSettingsRouter.Use(hs.VDBAuthMiddleware, hs.VDBArchivedCheckMiddleware)
360360
internalDashboardNotificationSettingsRouter.Use(hs.VDBAuthMiddleware, hs.VDBArchivedCheckMiddleware)
361361
}
362362
dashboardSettingsEndpoints := []endpoint{
363363
{http.MethodGet, "/validator-dashboards/{dashboard_id}/groups/{group_id}/epochs/{epoch}", hs.PublicGetUserNotificationsValidatorDashboard, hs.InternalGetUserNotificationsValidatorDashboard},
364364
{http.MethodGet, "/account-dashboards/{dashboard_id}/groups/{group_id}/epochs/{epoch}", hs.PublicGetUserNotificationsAccountDashboard, hs.InternalGetUserNotificationsAccountDashboard},
365+
}
366+
addEndpointsToRouters(dashboardSettingsEndpoints, publicDashboardNotificationSettingsRouter, internalDashboardNotificationSettingsRouter)
367+
368+
publicActiveDashboardNotificationSettingsRouter := publicDashboardNotificationSettingsRouter.NewRoute().Subrouter()
369+
internalActiveDashboardNotificationSettingsRouter := internalDashboardNotificationSettingsRouter.NewRoute().Subrouter()
370+
// TODO add archivedCheck middleware to account dashboard endpoints once they are implemented
371+
if !debug {
372+
publicActiveDashboardNotificationSettingsRouter.Use(hs.VDBArchivedCheckMiddleware)
373+
internalActiveDashboardNotificationSettingsRouter.Use(hs.VDBArchivedCheckMiddleware)
374+
}
375+
activeDashboardSettingsEndpoints := []endpoint{
365376
{http.MethodPut, "/settings/validator-dashboards/{dashboard_id}/groups/{group_id}", hs.PublicPutUserNotificationSettingsValidatorDashboard, hs.InternalPutUserNotificationSettingsValidatorDashboard},
366377
{http.MethodPut, "/settings/account-dashboards/{dashboard_id}/groups/{group_id}", hs.PublicPutUserNotificationSettingsAccountDashboard, hs.InternalPutUserNotificationSettingsAccountDashboard},
367378
}
368-
addEndpointsToRouters(dashboardSettingsEndpoints, publicDashboardNotificationSettingsRouter, internalDashboardNotificationSettingsRouter)
379+
addEndpointsToRouters(activeDashboardSettingsEndpoints, publicActiveDashboardNotificationSettingsRouter, internalActiveDashboardNotificationSettingsRouter)
369380
}
370381

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

0 commit comments

Comments
 (0)