Sha256: 0203ec7e12df8404c838064f22b289ff1c62083ec27a31b6f483362fba99e24e
Contents?: true
Size: 974 Bytes
Versions: 2
Compression:
Stored size: 974 Bytes
Contents
class Webhooks::Outgoing::Event < ActiveRecord::Base include Webhooks::Outgoing::HasUuid belongs_to :team, class_name: Webhooks::Outgoing.team_model belongs_to :event_type, class_name: "Webhooks::Outgoing::EventType" belongs_to :subject, polymorphic: true has_many :deliveries, dependent: :destroy before_create do self.payload = generate_payload end def generate_payload { event_id: uuid, event_type: event_type_id, subject_id: subject_id, subject_type: subject_type, data: data } end def event_type_name payload.dig("event_type") end def endpoints team.webhooks_outgoing_endpoints.listening_for_event_type_id(event_type_id) end def deliver endpoints.each do |endpoint| unless endpoint.deliveries.where(event: self).any? endpoint.deliveries.create(event: self, endpoint_url: endpoint.url).deliver_async end end end def label_string short_uuid end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bullet_train-outgoing_webhooks-1.0.1 | lib/models/webhooks/outgoing/event.rb |
bullet_train-outgoing_webhooks-1.0.0 | lib/models/webhooks/outgoing/event.rb |