2020-02-14 17:49:17 +00:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: webhooks
|
|
|
|
#
|
2020-02-26 04:14:24 +00:00
|
|
|
# id :bigint not null, primary key
|
|
|
|
# url :string
|
|
|
|
# webhook_type :integer default("account")
|
|
|
|
# created_at :datetime not null
|
|
|
|
# updated_at :datetime not null
|
|
|
|
# account_id :integer
|
|
|
|
# inbox_id :integer
|
2020-02-14 17:49:17 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
class Webhook < ApplicationRecord
|
|
|
|
belongs_to :account
|
2020-02-26 04:14:24 +00:00
|
|
|
belongs_to :inbox, optional: true
|
2020-02-14 17:49:17 +00:00
|
|
|
|
|
|
|
validates :account_id, presence: true
|
2020-02-29 12:13:49 +00:00
|
|
|
validates :url, uniqueness: { scope: [:account_id] }, format: { with: URI::DEFAULT_PARSER.make_regexp }
|
2020-02-26 04:14:24 +00:00
|
|
|
|
|
|
|
enum webhook_type: { account: 0, inbox: 1 }
|
2020-02-14 17:49:17 +00:00
|
|
|
end
|