Feature: Twilio SMS Channel (#658)

Twilio SMS Channel
Fixes :  #350
This commit is contained in:
Pranav Raj S
2020-04-05 22:11:27 +05:30
committed by GitHub
parent 8e59564793
commit a1a81e3799
44 changed files with 918 additions and 33 deletions

View File

@@ -23,9 +23,10 @@ class Account < ApplicationRecord
has_many :messages, dependent: :destroy
has_many :contacts, dependent: :destroy
has_many :facebook_pages, dependent: :destroy, class_name: '::Channel::FacebookPage'
has_many :telegram_bots, dependent: :destroy
has_many :twilio_sms, dependent: :destroy, class_name: '::Channel::TwilioSms'
has_many :twitter_profiles, dependent: :destroy, class_name: '::Channel::TwitterProfile'
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

View File

@@ -0,0 +1,33 @@
# == Schema Information
#
# Table name: channel_twilio_sms
#
# id :bigint not null, primary key
# account_sid :string not null
# auth_token :string not null
# phone_number :string not null
# created_at :datetime not null
# updated_at :datetime not null
# account_id :integer not null
#
# Indexes
#
# index_channel_twilio_sms_on_account_id_and_phone_number (account_id,phone_number) UNIQUE
#
class Channel::TwilioSms < ApplicationRecord
self.table_name = 'channel_twilio_sms'
validates :account_id, presence: true
validates :account_sid, presence: true
validates :auth_token, presence: true
validates :phone_number, uniqueness: { scope: :account_id }, presence: true
belongs_to :account
has_one :inbox, as: :channel, dependent: :destroy
def name
'Twilio SMS'
end
end

View File

@@ -11,6 +11,10 @@
# account_id :integer not null
# profile_id :string not null
#
# Indexes
#
# index_channel_twitter_profiles_on_account_id_and_profile_id (account_id,profile_id) UNIQUE
#
class Channel::TwitterProfile < ApplicationRecord
self.table_name = 'channel_twitter_profiles'

View File

@@ -113,6 +113,8 @@ class Message < ApplicationRecord
::Facebook::SendReplyService.new(message: self).perform
elsif channel_name == 'Channel::TwitterProfile'
::Twitter::SendReplyService.new(message: self).perform
elsif channel_name == 'Channel::TwilioSms'
::Twilio::OutgoingMessageService.new(message: self).perform
end
end

View File

@@ -10,6 +10,10 @@
# account_id :integer
# inbox_id :integer
#
# Indexes
#
# index_webhooks_on_account_id_and_url (account_id,url) UNIQUE
#
class Webhook < ApplicationRecord
belongs_to :account