diff --git a/app/controllers/services/lightning_controller.rb b/app/controllers/services/lightning_controller.rb index e38445b..386c950 100644 --- a/app/controllers/services/lightning_controller.rb +++ b/app/controllers/services/lightning_controller.rb @@ -17,39 +17,40 @@ class Services::LightningController < ApplicationController end def qr_lnurlp - lnurlp_url = "https://kosmos.org/.well-known/lnurlp/#{current_user.cn}" - lnurlp_bech32 = Lnurl.new(lnurlp_url).to_bech32 - qr_code = RQRCode::QRCode.new("lightning:" + lnurlp_bech32) + respond_to do |format| + lnurlp_url = "https://kosmos.org/.well-known/lnurlp/#{current_user.cn}" + lnurlp_bech32 = Lnurl.new(lnurlp_url).to_bech32 + qr_code = RQRCode::QRCode.new("lightning:" + lnurlp_bech32) - if params[:format] == "svg" - qr_svg = qr_code.as_svg( - color: "000", - shape_rendering: "crispEdges", - module_size: 6, - standalone: true, - use_path: true, - svg_attributes: { - class: 'inline-block' - } - ) - send_data( - qr_svg, - filename: "bitcoin-lightning-#{current_user.address}.svg", - type: "image/svg+xml" - ) - elsif params[:format] == "png" - qr_png = qr_code.as_png( - fill: "white", - color: "black", - size: 1024, - ) - send_data( - qr_png, - filename: "bitcoin-lightning-#{current_user.address}.png", - type: "image/png" - ) - else - http_status :not_found + format.svg do + qr_svg = qr_code.as_svg( + color: "000", + shape_rendering: "crispEdges", + module_size: 6, + standalone: true, + use_path: true, + svg_attributes: { + class: 'inline-block' + } + ) + send_data( + qr_svg, + filename: "bitcoin-lightning-#{current_user.address}.svg", + type: "image/svg+xml" + ) + end + format.png do + qr_png = qr_code.as_png( + fill: "white", + color: "black", + size: 1024, + ) + send_data( + qr_png, + filename: "bitcoin-lightning-#{current_user.address}.png", + type: "image/png" + ) + end end end