Feature: Webhooks (#489)

This commit is contained in:
Subin T P
2020-02-14 23:19:17 +05:30
committed by GitHub
parent 79a847aeab
commit 919261d843
29 changed files with 566 additions and 214 deletions

View File

@@ -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

View File

@@ -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
View 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