2020-04-05 16:41:27 +00:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: channel_twilio_sms
|
|
|
|
#
|
|
|
|
# id :bigint not null, primary key
|
|
|
|
# account_sid :string not null
|
|
|
|
# auth_token :string not null
|
2020-04-29 20:11:13 +00:00
|
|
|
# medium :integer default("sms")
|
2020-04-05 16:41:27 +00:00
|
|
|
# phone_number :string not null
|
|
|
|
# created_at :datetime not null
|
|
|
|
# updated_at :datetime not null
|
|
|
|
# account_id :integer not null
|
|
|
|
#
|
|
|
|
# Indexes
|
|
|
|
#
|
2022-05-07 12:27:16 +00:00
|
|
|
# index_channel_twilio_sms_on_account_sid_and_phone_number (account_sid,phone_number) UNIQUE
|
|
|
|
# index_channel_twilio_sms_on_phone_number (phone_number) UNIQUE
|
2020-04-05 16:41:27 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
class Channel::TwilioSms < ApplicationRecord
|
2021-09-10 20:01:17 +00:00
|
|
|
include Channelable
|
|
|
|
|
2020-04-05 16:41:27 +00:00
|
|
|
self.table_name = 'channel_twilio_sms'
|
|
|
|
|
|
|
|
validates :account_sid, presence: true
|
|
|
|
validates :auth_token, presence: true
|
2022-05-07 12:27:16 +00:00
|
|
|
# NOTE: allowing nil for future when we suppor twilio messaging services
|
|
|
|
# https://github.com/chatwoot/chatwoot/pull/4242
|
|
|
|
validates :phone_number, uniqueness: true, allow_nil: true
|
2020-04-05 16:41:27 +00:00
|
|
|
|
2020-04-29 20:11:13 +00:00
|
|
|
enum medium: { sms: 0, whatsapp: 1 }
|
|
|
|
|
2020-09-04 13:43:47 +00:00
|
|
|
def name
|
2020-09-17 18:02:19 +00:00
|
|
|
medium == 'sms' ? 'Twilio SMS' : 'Whatsapp'
|
2020-07-25 17:24:45 +00:00
|
|
|
end
|
|
|
|
|
2020-09-04 13:43:47 +00:00
|
|
|
def has_24_hour_messaging_window?
|
2020-09-17 18:02:19 +00:00
|
|
|
medium == 'whatsapp'
|
2020-04-05 16:41:27 +00:00
|
|
|
end
|
|
|
|
end
|