Class: MailboxReprocessWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Status::Worker, Sidekiq::Worker
Defined in:
app/workers/mailbox_reprocess_worker.rb

Overview

Reprocesses inbound communications whose raw email is still available in
ActiveStorage, applying the new mailbox capabilities retroactively:

  1. Body upgrade — upgrades plain-text bodies to the richer HTML part when
    one exists in the original email.
  2. MIME parts — saves inline images / attachments as Upload records and
    replaces cid: references in the body (only when the comm
    has no uploads yet, to avoid duplicates).
  3. Linked files — best-effort download of Google Drive share links, direct
    image/PDF URLs, etc. found in the HTML body.

Usage

Enqueue all eligible (text-body) communications:
MailboxReprocessWorker.perform_async

Force mode — also re-runs linked-file fetching on already-HTML bodies:
MailboxReprocessWorker.perform_async(nil, 'force' => true)

Single communication:
MailboxReprocessWorker.perform_async(8433845)

Instance Method Summary collapse

Instance Method Details

#perform(communication_id = nil, options = {}) ⇒ Object

Parameters:

  • communication_id (Integer, nil) (defaults to: nil)
  • options (Hash) (defaults to: {})

    'force' => true re-runs linked-file fetch even on
    already-HTML bodies (safe — only adds new uploads)



32
33
34
35
36
37
38
39
40
# File 'app/workers/mailbox_reprocess_worker.rb', line 32

def perform(communication_id = nil, options = {})
  force = options['force'] || false

  if communication_id.nil?
    bulk_enqueue(force:)
  else
    process_one(communication_id.to_i, force:)
  end
end