hackatime/app/controllers/settings/notifications_controller.rb
Mahad Kalam 28fa174861
Add Sentry monitoring for previously unreported errors (#1066)
* Add Sentry monitoring for previously unreported errors

* Fix

* Fixes

* whoops!
2026-03-13 11:06:12 +00:00

35 lines
1 KiB
Ruby

class Settings::NotificationsController < Settings::BaseController
def show
render_notifications
end
def update
list = "weekly_summary"
enabled = params.dig(:user, :weekly_summary_email_enabled)
begin
if enabled == "1" || enabled == true
@user.subscribe(list) unless @user.subscribed?(list)
else
@user.unsubscribe(list) if @user.subscribed?(list)
end
PosthogService.capture(@user, "settings_updated", { fields: [ "weekly_summary_email_enabled" ] })
redirect_to my_settings_notifications_path, notice: "Settings updated successfully"
rescue => e
report_error(e, message: "Failed to update notification settings")
flash.now[:error] = "Failed to update settings, sorry :("
render_notifications(status: :unprocessable_entity)
end
end
private
def render_notifications(status: :ok)
render_settings_page(
active_section: "notifications",
settings_update_path: my_settings_notifications_path,
status: status
)
end
end