Feature: Webhooks (#489)
This commit is contained in:
@@ -22,6 +22,7 @@ class Account < ApplicationRecord
|
||||
has_many :web_widgets, dependent: :destroy, class_name: '::Channel::WebWidget'
|
||||
has_many :telegram_bots, dependent: :destroy
|
||||
has_many :canned_responses, dependent: :destroy
|
||||
has_many :webhooks, dependent: :destroy
|
||||
has_one :subscription, dependent: :destroy
|
||||
|
||||
after_create :create_subscription
|
||||
|
||||
@@ -32,6 +32,7 @@ class Inbox < ApplicationRecord
|
||||
has_many :members, through: :inbox_members, source: :user
|
||||
has_many :conversations, dependent: :destroy
|
||||
has_many :messages, through: :conversations
|
||||
has_one :webhook, dependent: :destroy
|
||||
after_create :subscribe_webhook, if: :facebook?
|
||||
after_destroy :delete_round_robin_agents
|
||||
|
||||
|
||||
20
app/models/webhook.rb
Normal file
20
app/models/webhook.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: webhooks
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# urls :string
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# account_id :integer
|
||||
# inbox_id :integer
|
||||
#
|
||||
|
||||
class Webhook < ApplicationRecord
|
||||
belongs_to :account
|
||||
belongs_to :inbox
|
||||
|
||||
validates :account_id, presence: true
|
||||
validates :inbox_id, presence: true
|
||||
serialize :urls, Array
|
||||
end
|
||||
Reference in New Issue
Block a user