Class: WebhookProcessors::SftpgoProcessor
- Inherits:
-
Object
- Object
- WebhookProcessors::SftpgoProcessor
- Defined in:
- app/services/webhook_processors/sftpgo_processor.rb
Overview
Processes an SFTPGo recording_uploaded webhook (see
Webhooks::V1::SftpgoController) by enqueuing the single-file import for the
recording that just landed in R2.
The work itself is owned by CallRecordImporterWorker — this processor only
bridges the webhook to it. Enqueuing perform_async(wav_key) (rather than
importing inline) is deliberate: it shares the worker's :until_executed
lock with the hourly poll, so a recording that lands on the hour can't be
imported twice. CallRecordSwitchvoxImporterFile is idempotent on top of
that (first_or_initialize on the unique recorded-call id), and the file is
archived to processed/ after a successful import, so re-delivery is safe.
Class Method Summary collapse
Instance Method Summary collapse
-
#call ⇒ Hash
Stored on the WebhookLog as response_data.
-
#initialize(webhook_log) ⇒ SftpgoProcessor
constructor
A new instance of SftpgoProcessor.
Constructor Details
#initialize(webhook_log) ⇒ SftpgoProcessor
Returns a new instance of SftpgoProcessor.
23 24 25 |
# File 'app/services/webhook_processors/sftpgo_processor.rb', line 23 def initialize(webhook_log) @webhook_log = webhook_log end |
Class Method Details
.call(webhook_log) ⇒ Object
19 20 21 |
# File 'app/services/webhook_processors/sftpgo_processor.rb', line 19 def self.call(webhook_log) new(webhook_log).call end |
Instance Method Details
#call ⇒ Hash
Returns stored on the WebhookLog as response_data.
28 29 30 31 32 33 34 35 |
# File 'app/services/webhook_processors/sftpgo_processor.rb', line 28 def call wav_key = @webhook_log.external_id.presence raise ArgumentError, 'SFTPGo webhook missing wav_key (external_id)' if wav_key.nil? jid = CallRecordImporterWorker.perform_async(wav_key) Rails.logger.info "[WebhookProcessors::Sftpgo] Enqueued import #{wav_key} (jid #{jid || 'deduped'})" { enqueued: wav_key, jid: jid } end |