Class: WhatsAppNotifier::SessionsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- WhatsAppNotifier::SessionsController
- Defined in:
- app/controllers/whatsapp_notifier/sessions_controller.rb
Instance Method Summary collapse
-
#qr ⇒ Object
GET /qr — the latest QR for the current user (nil while initializing).
-
#show ⇒ Object
GET /status — connection state for the current user.
Instance Method Details
#qr ⇒ Object
GET /qr — the latest QR for the current user (nil while initializing)
13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/whatsapp_notifier/sessions_controller.rb', line 13 def qr qr_code = WhatsAppNotifier.scan_qr(metadata: ) if qr_code render json: { qr: qr_code } else render json: { error: "No QR available" }, status: :not_found end rescue StandardError => e render json: { error: "Failed to fetch QR: #{e.}" }, status: :internal_server_error end |
#show ⇒ Object
GET /status — connection state for the current user
4 5 6 7 8 9 10 |
# File 'app/controllers/whatsapp_notifier/sessions_controller.rb', line 4 def show data = WhatsAppNotifier.connection_status(metadata: ) render json: data.merge(hasQR: data[:has_qr]) rescue StandardError => e render json: { error: "Failed to fetch status: #{e.}" }, status: :internal_server_error end |