module Admin class NotificationsController < BaseController def show @admin = current_admin end def update @admin = current_admin if @admin.update(admin_params) redirect_to admin_notifications_path, notice: "Notification settings saved" else flash.now[:alert] = "Failed to save settings" render :show, status: :unprocessable_entity end end def test admin = current_admin if admin.ntfy_configured? SendNtfyNotificationJob.perform_now( admin.id, "test_notification", title: "Test notification from MySMSAPio", message: "If you can read this, your ntfy setup is working! Sent at #{Time.current.strftime('%H:%M:%S')}.", priority: 3, tags: [ "tada", "white_check_mark" ] ) redirect_to admin_notifications_path, notice: "Test notification sent" else redirect_to admin_notifications_path, alert: "Configure ntfy topic and token first" end end private def admin_params params.require(:admin_user).permit(:ntfy_enabled, :ntfy_topic, :ntfy_token, :ntfy_server_url) end end end