Module: Webhooks::Outgoing::TeamSupport

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/webhooks/outgoing/team_support.rb

Instance Method Summary collapse

Instance Method Details

#endpoint_api_versions_for_event_type(event_type) ⇒ Object



15
16
17
# File 'app/models/concerns/webhooks/outgoing/team_support.rb', line 15

def endpoint_api_versions_for_event_type(event_type)
  webhooks_outgoing_endpoints.listening_for_event_type_id(event_type.id).pluck(:api_version).uniq
end

#endpoint_api_versions_listening_for_event_type(event_type) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/concerns/webhooks/outgoing/team_support.rb', line 19

def endpoint_api_versions_listening_for_event_type(event_type)
  if should_cache_endpoints_listening_for_event_type?
    key = "#{cache_key_with_version}/endpoints_for_event_type/#{event_type.cache_key}/api_version"

    Rails.cache.fetch(key, expires_in: 24.hours, race_condition_ttl: 5.seconds) do
      endpoint_api_versions_for_event_type(event_type)
    end
  else
    endpoint_api_versions_for_event_type(event_type)
  end
end

#mark_for_destructionObject



31
32
33
34
# File 'app/models/concerns/webhooks/outgoing/team_support.rb', line 31

def mark_for_destruction
  # This allows downstream logic to check whether a team is being destroyed in order to bypass webhook issuance.
  update_column(:being_destroyed, true)
end

#should_cache_endpoints_listening_for_event_type?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'app/models/concerns/webhooks/outgoing/team_support.rb', line 11

def should_cache_endpoints_listening_for_event_type?
  true
end