Class: Jobs::EmitWebHookEvent

Inherits:
Base
  • Object
show all
Defined in:
app/jobs/regular/emit_web_hook_event.rb

Constant Summary collapse

PING_EVENT =
"ping"
MAX_RETRY_COUNT =
4
RETRY_BACKOFF =
5

Instance Method Summary collapse

Methods inherited from Base

acquire_cluster_concurrency_lock!, clear_cluster_concurrency_lock!, cluster_concurrency, cluster_concurrency_redis_key, delayed_perform, #error_context, get_cluster_concurrency, #last_db_duration, #log, #perform, #perform_immediately

Instance Method Details

#execute(args) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/jobs/regular/emit_web_hook_event.rb', line 13

def execute(args)
  @arguments = args
  @retry_count = args[:retry_count] || 0
  @web_hook = WebHook.find_by(id: @arguments[:web_hook_id])
  validate_arguments!

  return if @web_hook.blank? # Web Hook was deleted

  unless ping_event?(@arguments[:event_type])
    validate_argument!(:payload)

    return if webhook_inactive?
    return if group_webhook_invalid?
    return if category_webhook_invalid?
    return if tag_webhook_invalid?
  end

  send_webhook!
end