Class: Contentful::Scheduler::Controller

Inherits:
Webhook::Listener::Controllers::WebhookAware
  • Object
show all
Defined in:
lib/contentful/scheduler/controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject Also known as: save, auto_save, unarchive



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/contentful/scheduler/controller.rb', line 8

def create
  return unless webhook.entry?

  if !Auth.new(webhook).auth
    logger.warn "Skipping - Authentication failed for Space: #{webhook.space_id} - Entry: #{webhook.id}"
    return
  end

  logger.info "Queueing - Space: #{webhook.space_id} - Entry: #{webhook.id}"

  Queue.instance(logger).update_or_create(webhook)
end

#deleteObject Also known as: unpublish, archive, publish



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/contentful/scheduler/controller.rb', line 24

def delete
  return unless webhook.entry?

  if !Auth.new(webhook).auth
    logger.warn "Skipping - Authentication failed for Space: #{webhook.space_id} - Entry: #{webhook.id}"
    return
  end

  logger.info "Unqueueing - Space: #{webhook.space_id} - Entry: #{webhook.id}"

  Queue.instance(logger).remove(webhook)
end