Skip to content

Commit

Permalink
refactor: split api block proposal success & miss notification events
Browse files Browse the repository at this point in the history
See: BEDS-1078
  • Loading branch information
LuccaBitfly committed Jan 15, 2025
1 parent d219720 commit 1b58ca9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions backend/pkg/api/data_access/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -1681,8 +1681,10 @@ func (d *DataAccessService) GetNotificationSettingsDashboards(ctx context.Contex
settings.GroupEfficiencyBelowThreshold = event.Threshold
case types.ValidatorMissedAttestationEventName:
settings.IsAttestationsMissedSubscribed = true
case types.ValidatorMissedProposalEventName, types.ValidatorExecutedProposalEventName:
settings.IsBlockProposalSubscribed = true
case types.ValidatorExecutedProposalEventName:
settings.IsBlockProposalSuccessSubscribed = true
case types.ValidatorMissedProposalEventName:
settings.IsBlockProposalMissedSubscribed = true
case types.ValidatorUpcomingProposalEventName:
settings.IsUpcomingBlockProposalSubscribed = true
case types.SyncCommitteeSoonEventName:
Expand Down Expand Up @@ -1922,9 +1924,8 @@ func (d *DataAccessService) UpdateNotificationSettingsValidatorDashboard(ctx con
d.AddOrRemoveEvent(&eventsToInsert, &eventsToDelete, settings.IsSlashedSubscribed, userId, types.ValidatorGotSlashedEventName, networkName, eventFilter, epoch, 0)
d.AddOrRemoveEvent(&eventsToInsert, &eventsToDelete, settings.IsMaxCollateralSubscribed, userId, types.RocketpoolCollateralMaxReachedEventName, networkName, eventFilter, epoch, settings.MaxCollateralThreshold)
d.AddOrRemoveEvent(&eventsToInsert, &eventsToDelete, settings.IsMinCollateralSubscribed, userId, types.RocketpoolCollateralMinReachedEventName, networkName, eventFilter, epoch, settings.MinCollateralThreshold)
// Set two events for IsBlockProposalSubscribed
d.AddOrRemoveEvent(&eventsToInsert, &eventsToDelete, settings.IsBlockProposalSubscribed, userId, types.ValidatorMissedProposalEventName, networkName, eventFilter, epoch, 0)
d.AddOrRemoveEvent(&eventsToInsert, &eventsToDelete, settings.IsBlockProposalSubscribed, userId, types.ValidatorExecutedProposalEventName, networkName, eventFilter, epoch, 0)
d.AddOrRemoveEvent(&eventsToInsert, &eventsToDelete, settings.IsBlockProposalSuccessSubscribed, userId, types.ValidatorMissedProposalEventName, networkName, eventFilter, epoch, 0)
d.AddOrRemoveEvent(&eventsToInsert, &eventsToDelete, settings.IsBlockProposalMissedSubscribed, userId, types.ValidatorExecutedProposalEventName, networkName, eventFilter, epoch, 0)

// Insert all the events or update the threshold if they already exist
if len(eventsToInsert) > 0 {
Expand Down
3 changes: 2 additions & 1 deletion backend/pkg/api/types/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ type NotificationSettingsValidatorDashboard struct {
IsGroupEfficiencyBelowSubscribed bool `json:"is_group_efficiency_below_subscribed"`
GroupEfficiencyBelowThreshold float64 `json:"group_efficiency_below_threshold" faker:"boundary_start=0, boundary_end=1"`
IsAttestationsMissedSubscribed bool `json:"is_attestations_missed_subscribed"`
IsBlockProposalSubscribed bool `json:"is_block_proposal_subscribed"`
IsBlockProposalSuccessSubscribed bool `json:"is_block_proposal_success_subscribed"`
IsBlockProposalMissedSubscribed bool `json:"is_block_proposal_missed_subscribed"`
IsUpcomingBlockProposalSubscribed bool `json:"is_upcoming_block_proposal_subscribed"`
IsSyncSubscribed bool `json:"is_sync_subscribed"`
IsWithdrawalProcessedSubscribed bool `json:"is_withdrawal_processed_subscribed"`
Expand Down

0 comments on commit 1b58ca9

Please sign in to comment.