Class: CollavreSlack::SlackInboundMessageUpdateJob

Inherits:
ApplicationJob
  • Object
show all
Includes:
ErrorLoggable
Defined in:
app/jobs/collavre_slack/slack_inbound_message_update_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(payload) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/jobs/collavre_slack/slack_inbound_message_update_job.rb', line 7

def perform(payload)
  with_slack_error_handling("SlackInboundMessageUpdateJob") do
    data = payload.with_indifferent_access
    comment = Collavre::Comment.find_by(id: data[:comment_id])
    return unless comment

    new_content = data[:content]
    return if new_content.blank?

    # Mark as coming from Slack to prevent loop
    comment.instance_variable_set(:@from_slack, true)
    comment.update!(content: new_content)

    Rails.logger.info("[CollavreSlack] Updated comment #{comment.id} from Slack edit")
  end
end