Skip to content

Commit

Permalink
refactor: remove notifications realtime mode from backend
Browse files Browse the repository at this point in the history
See: BEDS-847
  • Loading branch information
LuccaBitfly committed Oct 22, 2024
1 parent 36b1339 commit 286f978
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 23 deletions.
6 changes: 1 addition & 5 deletions backend/pkg/api/data_access/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,6 @@ func (d *DataAccessService) GetNotificationSettingsDashboards(ctx context.Contex
Network uint64 `db:"network"`
WebhookUrl sql.NullString `db:"webhook_target"`
IsWebhookDiscordEnabled sql.NullBool `db:"discord_webhook"`
IsRealTimeModeEnabled sql.NullBool `db:"realtime_notifications"`
}{}
wg.Go(func() error {
err := d.alloyReader.SelectContext(ctx, &valDashboards, `
Expand All @@ -1762,7 +1761,6 @@ func (d *DataAccessService) GetNotificationSettingsDashboards(ctx context.Contex
d.network,
g.webhook_target,
(g.webhook_format = $1) AS discord_webhook,
g.realtime_notifications
FROM users_val_dashboards d
INNER JOIN users_val_dashboards_groups g ON d.id = g.dashboard_id
WHERE d.user_id = $2`, DiscordWebhookFormat, userId)
Expand Down Expand Up @@ -1923,7 +1921,6 @@ func (d *DataAccessService) GetNotificationSettingsDashboards(ctx context.Contex
if valSettings, ok := resultMap[key].Settings.(*t.NotificationSettingsValidatorDashboard); ok {
valSettings.WebhookUrl = valDashboard.WebhookUrl.String
valSettings.IsWebhookDiscordEnabled = valDashboard.IsWebhookDiscordEnabled.Bool
valSettings.IsRealTimeModeEnabled = valDashboard.IsRealTimeModeEnabled.Bool
}
}

Expand Down Expand Up @@ -2150,8 +2147,7 @@ func (d *DataAccessService) UpdateNotificationSettingsValidatorDashboard(ctx con
SET
webhook_target = NULLIF($1, ''),
webhook_format = CASE WHEN $2 THEN $3 ELSE NULL END,
realtime_notifications = CASE WHEN $4 THEN TRUE ELSE NULL END
WHERE dashboard_id = $5 AND id = $6`, settings.WebhookUrl, settings.IsWebhookDiscordEnabled, DiscordWebhookFormat, settings.IsRealTimeModeEnabled, dashboardId, groupId)
WHERE dashboard_id = $4 AND id = $5`, settings.WebhookUrl, settings.IsWebhookDiscordEnabled, DiscordWebhookFormat, dashboardId, groupId)
if err != nil {
return err
}
Expand Down
7 changes: 0 additions & 7 deletions backend/pkg/api/handlers/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -2499,9 +2499,6 @@ func (h *HandlerService) PublicGetUserNotificationSettingsDashboards(w http.Resp
settings.IsGroupEfficiencyBelowSubscribed = false
settings.GroupEfficiencyBelowThreshold = defaultSettings.GroupEfficiencyBelowThreshold
}
if !userInfo.PremiumPerks.NotificationsValidatorDashboardRealTimeMode && settings.IsRealTimeModeEnabled {
settings.IsRealTimeModeEnabled = false
}
data[i].Settings = settings
}
response := types.InternalGetUserNotificationSettingsDashboardsResponse{
Expand Down Expand Up @@ -2557,10 +2554,6 @@ func (h *HandlerService) PublicPutUserNotificationSettingsValidatorDashboard(w h
returnForbidden(w, r, errors.New("user does not have premium perks to subscribe group efficiency event"))
return
}
if !userInfo.PremiumPerks.NotificationsValidatorDashboardRealTimeMode && req.IsRealTimeModeEnabled {
returnForbidden(w, r, errors.New("user does not have premium perks to subscribe real time mode"))
return
}

err = h.getDataAccessor(r).UpdateNotificationSettingsValidatorDashboard(r.Context(), userId, dashboardId, groupId, req)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion backend/pkg/api/types/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ type InternalGetUserNotificationSettingsResponse ApiDataResponse[NotificationSet
type NotificationSettingsValidatorDashboard struct {
WebhookUrl string `json:"webhook_url" faker:"url"`
IsWebhookDiscordEnabled bool `json:"is_webhook_discord_enabled"`
IsRealTimeModeEnabled bool `json:"is_real_time_mode_enabled"`

IsValidatorOfflineSubscribed bool `json:"is_validator_offline_subscribed"`
IsGroupEfficiencyBelowSubscribed bool `json:"is_group_efficiency_below_subscribed"`
Expand Down
3 changes: 1 addition & 2 deletions backend/pkg/api/types/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ type PremiumPerks struct {
MonitorMachines uint64 `json:"monitor_machines"`
MachineMonitoringHistorySeconds uint64 `json:"machine_monitoring_history_seconds"`
NotificationsMachineCustomThreshold bool `json:"notifications_machine_custom_threshold"`
NotificationsValidatorDashboardRealTimeMode bool `json:"notifications_validator_dashboard_real_time_mode"`
NotificationsValidatorDashboardGroupEfficiency bool `json:"notifications_validator_dashboard_group_offline"`
NotificationsValidatorDashboardGroupEfficiency bool `json:"notifications_validator_dashboard_group_efficiency"`
}

// TODO @patrick post-beta StripeCreateCheckoutSession and StripeCustomerPortal are currently served from v1 (loadbalanced), Once V1 is not affected by this anymore, consider wrapping this with ApiDataResponse
Expand Down
5 changes: 0 additions & 5 deletions backend/pkg/commons/db/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ var freeTierProduct t.PremiumProduct = t.PremiumProduct{
MonitorMachines: 1,
MachineMonitoringHistorySeconds: 3600 * 3,
NotificationsMachineCustomThreshold: false,
NotificationsValidatorDashboardRealTimeMode: false,
NotificationsValidatorDashboardGroupEfficiency: false,
},
PricePerMonthEur: 0,
Expand Down Expand Up @@ -78,7 +77,6 @@ var adminPerks = t.PremiumPerks{
MonitorMachines: maxJsInt,
MachineMonitoringHistorySeconds: maxJsInt,
NotificationsMachineCustomThreshold: true,
NotificationsValidatorDashboardRealTimeMode: true,
NotificationsValidatorDashboardGroupEfficiency: true,
}

Expand Down Expand Up @@ -359,7 +357,6 @@ func GetProductSummary(ctx context.Context) (*t.ProductSummary, error) { // TODO
MonitorMachines: 2,
MachineMonitoringHistorySeconds: 3600 * 24 * 30,
NotificationsMachineCustomThreshold: true,
NotificationsValidatorDashboardRealTimeMode: true,
NotificationsValidatorDashboardGroupEfficiency: true,
},
PricePerMonthEur: 9.99,
Expand Down Expand Up @@ -394,7 +391,6 @@ func GetProductSummary(ctx context.Context) (*t.ProductSummary, error) { // TODO
MonitorMachines: 10,
MachineMonitoringHistorySeconds: 3600 * 24 * 30,
NotificationsMachineCustomThreshold: true,
NotificationsValidatorDashboardRealTimeMode: true,
NotificationsValidatorDashboardGroupEfficiency: true,
},
PricePerMonthEur: 29.99,
Expand Down Expand Up @@ -429,7 +425,6 @@ func GetProductSummary(ctx context.Context) (*t.ProductSummary, error) { // TODO
MonitorMachines: 10,
MachineMonitoringHistorySeconds: 3600 * 24 * 30,
NotificationsMachineCustomThreshold: true,
NotificationsValidatorDashboardRealTimeMode: true,
NotificationsValidatorDashboardGroupEfficiency: true,
},
PricePerMonthEur: 49.99,
Expand Down
1 change: 0 additions & 1 deletion frontend/types/api/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ export type InternalGetUserNotificationSettingsResponse = ApiDataResponse<Notifi
export interface NotificationSettingsValidatorDashboard {
webhook_url: string;
is_webhook_discord_enabled: boolean;
is_real_time_mode_enabled: boolean;
is_validator_offline_subscribed: boolean;
is_group_efficiency_below_subscribed: boolean;
group_efficiency_below_threshold: number /* float64 */;
Expand Down
3 changes: 1 addition & 2 deletions frontend/types/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ export interface PremiumPerks {
monitor_machines: number /* uint64 */;
machine_monitoring_history_seconds: number /* uint64 */;
notifications_machine_custom_threshold: boolean;
notifications_validator_dashboard_real_time_mode: boolean;
notifications_validator_dashboard_group_offline: boolean;
notifications_validator_dashboard_group_efficiency: boolean;
}
export interface StripeCreateCheckoutSession {
sessionId?: string;
Expand Down

0 comments on commit 286f978

Please sign in to comment.