Class: WCC::Contentful::WebhookController

Inherits:
ApplicationController show all
Includes:
ServiceAccessors, Wisper::Publisher
Defined in:
app/controllers/wcc/contentful/webhook_controller.rb

Overview

The WebhookController is mounted by the WCC::Contentful::Engine to receive webhook events from Contentful. It passes these webhook events to the jobs configured in WCC::Contentful::Configuration#webhook_jobs

Instance Method Summary collapse

Instance Method Details

#receiveObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/wcc/contentful/webhook_controller.rb', line 20

def receive
  params.require('sys').require(%w[id type])
  params.permit('sys', 'fields')
  event = params.slice('sys', 'fields').permit!.to_h

  return unless check_environment(event)

  # Immediately update the store, we may update again later using SyncEngine::Job.
  store.index(event) if store.index?

  event = WCC::Contentful::Event.from_raw(event, source: self)
  emit_event(event)
end