Class: CollavreSlack::SlackInboundMessageDeleteJob

Inherits:
ApplicationJob
  • Object
show all
Includes:
ErrorLoggable
Defined in:
app/jobs/collavre_slack/slack_inbound_message_delete_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
23
24
# File 'app/jobs/collavre_slack/slack_inbound_message_delete_job.rb', line 7

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

    if comment
      # Mark as coming from Slack to prevent loop
      comment.instance_variable_set(:@from_slack, true)
      comment.destroy!
      Rails.logger.info("[CollavreSlack] Deleted comment #{data[:comment_id]} from Slack deletion")
    end

    # Clean up the comment link record
    if data[:slack_comment_link_id].present?
      SlackCommentLink.find_by(id: data[:slack_comment_link_id])&.destroy
    end
  end
end