diff --git a/app/controllers/admin/gateways_controller.rb b/app/controllers/admin/gateways_controller.rb index d3e46d9..c583fb9 100644 --- a/app/controllers/admin/gateways_controller.rb +++ b/app/controllers/admin/gateways_controller.rb @@ -50,37 +50,7 @@ module Admin @recent_messages = SmsMessage.where(gateway_id: @gateway.id).order(created_at: :desc).limit(20) end end - - private - - def generate_qr_code_data(api_key) - require "rqrcode" - - # Determine the base URL and WebSocket URL - base_url = request.base_url - ws_url = request.base_url.sub(/^http/, "ws") + "/cable" - - # Create JSON configuration for the Android app - config_data = { - api_key: api_key, - api_base_url: base_url, - websocket_url: ws_url, - version: "1.0" - }.to_json - - # Generate QR code - qr = RQRCode::QRCode.new(config_data, level: :h) - - # Return as SVG string - qr.as_svg( - offset: 0, - color: "000", - shape_rendering: "crispEdges", - module_size: 4, - standalone: true, - use_path: true - ) - end + def toggle @gateway = Gateway.find(params[:id]) @@ -148,5 +118,36 @@ module Admin Rails.logger.error "Test SMS failed: #{e.message}\n#{e.backtrace.join("\n")}" render json: { status: "error", message: e.message }, status: :internal_server_error end + + private + + def generate_qr_code_data(api_key) + require "rqrcode" + + # Determine the base URL and WebSocket URL + base_url = request.base_url + ws_url = request.base_url.sub(/^http/, "ws") + "/cable" + + # Create JSON configuration for the Android app + config_data = { + api_key: api_key, + api_base_url: base_url, + websocket_url: ws_url, + version: "1.0" + }.to_json + + # Generate QR code + qr = RQRCode::QRCode.new(config_data, level: :h) + + # Return as SVG string + qr.as_svg( + offset: 0, + color: "000", + shape_rendering: "crispEdges", + module_size: 4, + standalone: true, + use_path: true + ) + end end -end +end \ No newline at end of file