Class: Raif::ConversationEntryJob

Inherits:
ApplicationJob show all
Defined in:
app/jobs/raif/conversation_entry_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(conversation_entry:) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/jobs/raif/conversation_entry_job.rb', line 15

def perform(conversation_entry:)
  conversation = conversation_entry.raif_conversation
  conversation_entry.process_entry!

  Turbo::StreamsChannel.broadcast_render_to conversation,
    partial: "raif/conversations/entry_processed",
    locals: { conversation: conversation, conversation_entry: conversation_entry }
rescue StandardError => e
  logger.error "Error processing conversation entry: #{e.message}"
  logger.error e.backtrace.join("\n")

  conversation_entry.raif_conversation.update_columns(generating_entry_response: false)
  conversation_entry.failed!
  conversation_entry.broadcast_replace_to conversation
end