Module: Webhooks::Incoming::Webhook

Included in:
BulletTrainWebhook
Defined in:
app/models/webhooks/incoming/webhook.rb

Instance Method Summary collapse

Instance Method Details

#mark_processedObject



21
22
23
# File 'app/models/webhooks/incoming/webhook.rb', line 21

def mark_processed
  touch(:processed_at)
end

#process_asyncObject



13
14
15
# File 'app/models/webhooks/incoming/webhook.rb', line 13

def process_async
  Webhooks::Incoming::WebhookProcessingJob.perform_later(self)
end

#processed?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/models/webhooks/incoming/webhook.rb', line 17

def processed?
  processed_at.present?
end

#verified?Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
# File 'app/models/webhooks/incoming/webhook.rb', line 6

def verified?
  unless verified_at
    touch(:verified_at) if verify_authenticity
  end
  verified_at.present?
end

#verify_and_processObject



25
26
27
28
29
30
31
# File 'app/models/webhooks/incoming/webhook.rb', line 25

def verify_and_process
  return if processed?
  if verified?
    process
    mark_processed
  end
end

#verify_authenticityObject



2
3
4
# File 'app/models/webhooks/incoming/webhook.rb', line 2

def verify_authenticity
  raise "you must either implement `verify_authenticity` in #{self.class.name} or perform verification and set `verified_at` in #{self.class.name}sController."
end