Class: LsaTdxFeedback::FeedbackController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/lsa_tdx_feedback/feedback_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/lsa_tdx_feedback/feedback_controller.rb', line 6

def create
  feedback_data = build_feedback_data

  # No fallback configured: preserve the original behavior exactly.
  return create_via_tdx(feedback_data) if LsaTdxFeedback.configuration.fallback.nil?

  # Fallback configured: file a TDX ticket when TDX is configured and the
  # call succeeds; otherwise hand the feedback to the fallback so it's never
  # lost (e.g. TDX creds absent, OAuth/API failure).
  if LsaTdxFeedback.configuration.valid?
    begin
      ticket = TicketClient.new.create_feedback_ticket(feedback_data)
      return render_ticket_created(ticket)
    rescue StandardError => e
      Rails.logger.error "LsaTdxFeedback: ticket failed (#{e.class}: #{e.message}); using fallback"
    end
  end

  deliver_via_fallback(feedback_data)
end