From 286f9784fc60177053e0a8e50df38ce7a4ae6b4b Mon Sep 17 00:00:00 2001 From: Lucca Dukic <109136188+LuccaBitfly@users.noreply.github.com> Date: Tue, 22 Oct 2024 10:39:15 +0200 Subject: [PATCH] refactor: remove notifications realtime mode from backend See: BEDS-847 --- backend/pkg/api/data_access/notifications.go | 6 +----- backend/pkg/api/handlers/public.go | 7 ------- backend/pkg/api/types/notifications.go | 1 - backend/pkg/api/types/user.go | 3 +-- backend/pkg/commons/db/user.go | 5 ----- frontend/types/api/notifications.ts | 1 - frontend/types/api/user.ts | 3 +-- 7 files changed, 3 insertions(+), 23 deletions(-) diff --git a/backend/pkg/api/data_access/notifications.go b/backend/pkg/api/data_access/notifications.go index 3601bdeb8..7c3fe0560 100644 --- a/backend/pkg/api/data_access/notifications.go +++ b/backend/pkg/api/data_access/notifications.go @@ -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, ` @@ -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) @@ -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 } } @@ -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 } diff --git a/backend/pkg/api/handlers/public.go b/backend/pkg/api/handlers/public.go index 3cd2e6634..128506d8b 100644 --- a/backend/pkg/api/handlers/public.go +++ b/backend/pkg/api/handlers/public.go @@ -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{ @@ -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 { diff --git a/backend/pkg/api/types/notifications.go b/backend/pkg/api/types/notifications.go index 21a70aecc..2b9e1bc24 100644 --- a/backend/pkg/api/types/notifications.go +++ b/backend/pkg/api/types/notifications.go @@ -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"` diff --git a/backend/pkg/api/types/user.go b/backend/pkg/api/types/user.go index b22a00e25..8e4a30dc7 100644 --- a/backend/pkg/api/types/user.go +++ b/backend/pkg/api/types/user.go @@ -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 diff --git a/backend/pkg/commons/db/user.go b/backend/pkg/commons/db/user.go index bf62ee8e2..8ad275f8b 100644 --- a/backend/pkg/commons/db/user.go +++ b/backend/pkg/commons/db/user.go @@ -46,7 +46,6 @@ var freeTierProduct t.PremiumProduct = t.PremiumProduct{ MonitorMachines: 1, MachineMonitoringHistorySeconds: 3600 * 3, NotificationsMachineCustomThreshold: false, - NotificationsValidatorDashboardRealTimeMode: false, NotificationsValidatorDashboardGroupEfficiency: false, }, PricePerMonthEur: 0, @@ -78,7 +77,6 @@ var adminPerks = t.PremiumPerks{ MonitorMachines: maxJsInt, MachineMonitoringHistorySeconds: maxJsInt, NotificationsMachineCustomThreshold: true, - NotificationsValidatorDashboardRealTimeMode: true, NotificationsValidatorDashboardGroupEfficiency: true, } @@ -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, @@ -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, @@ -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, diff --git a/frontend/types/api/notifications.ts b/frontend/types/api/notifications.ts index f78c3e0c8..067fa6778 100644 --- a/frontend/types/api/notifications.ts +++ b/frontend/types/api/notifications.ts @@ -187,7 +187,6 @@ export type InternalGetUserNotificationSettingsResponse = ApiDataResponse