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



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

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

  Turbo::StreamsChannel.broadcast_action_to(
    conversation,
    action: :raif_scroll_to_bottom,
    target: dom_id(conversation, :entries)
  )
rescue StandardError => e
  logger.error "Error processing conversation entry: #{e.message}"
  logger.error e.backtrace.join("\n")

  conversation_entry.failed!
  conversation_entry.broadcast_replace_to conversation
end