From c98072557273ff4383013f73621061ece34fc6d2 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 7 Mar 2013 02:36:38 -0500 Subject: call model table changed --- app/models/call.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/call.rb') diff --git a/app/models/call.rb b/app/models/call.rb index db6d9d6..b0cd9b2 100644 --- a/app/models/call.rb +++ b/app/models/call.rb @@ -1,5 +1,5 @@ class Call < ActiveRecord::Base - self.table_name = 'detailed_calls' + self.table_name = 'calls_active' self.primary_key = 'uuid' attr_writer :sip_account_id -- cgit v1.2.3 From 2964ebf277568536ac215f3a651e1841a73d68f8 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 7 Mar 2013 03:11:28 -0500 Subject: call origination fixed --- app/models/call.rb | 76 +++++++++++++----------------------------------------- 1 file changed, 18 insertions(+), 58 deletions(-) (limited to 'app/models/call.rb') diff --git a/app/models/call.rb b/app/models/call.rb index b0cd9b2..8f657fa 100644 --- a/app/models/call.rb +++ b/app/models/call.rb @@ -2,29 +2,31 @@ class Call < ActiveRecord::Base self.table_name = 'calls_active' self.primary_key = 'uuid' - attr_writer :sip_account_id + belongs_to :sip_account + belongs_to :b_sip_account, :class_name => SipAccount - validates :dest, + validates :sip_account_id, :presence => true - - def create(attributes=nil) - if ! attributes - return - end - self.sip_account = SipAccount.where(:id => attributes[:sip_account_id]).first - self.dest = attributes[:dest] - return self + validates :destination, + :presence => true + + def save(attributes=nil) end - def save(attributes=nil) - - end + def call + if self.sip_account && self.destination + return self.sip_account.call(self.destination) + end - def call(number=nil) - if @sip_account && self.dest - return @sip_account.call(self.dest) + if !self.sip_account + errors.add(:sip_account_id, 'no sip_account') end + + if self.destination.blank? + errors.add(:destination, 'no destination') + end + return false end @@ -37,38 +39,6 @@ class Call < ActiveRecord::Base return FreeswitchAPI.execute('uuid_kill', self.uuid, true); end - def sip_account=(sip_a) - @sip_account = sip_a - end - - def sip_account - if @sip_account - return @sip_account - end - - result = self.presence_id.match('^(.+)@(.+)$') - - if result && ! result[1].blank? and ! result[2].blank? - domain = SipDomain.where(:host => result[2]).first - if domain - @sip_account = SipAccount.where(:auth_name => result[1], :sip_domain_id => domain.id).first - end - end - - return @sip_account - end - - def sip_account_bleg - result = self.b_presence_id.match('^(.+)@(.+)$') - - if result && ! result[1].blank? and ! result[2].blank? - domain = SipDomain.where(:host => result[2]).first - if domain - return SipAccount.where(:auth_name => result[1], :sip_domain_id => domain.id).first - end - end - end - def get_variable_from_uuid(channel_uuid, variable_name) if channel_uuid.blank? return nil @@ -92,14 +62,4 @@ class Call < ActiveRecord::Base return get_variable_from_uuid(self.b_uuid, variable_name); end - def is_sip - return self.name.match('^sofia') != nil - end - - def is_caller - if (self.uuid == self.call_uuid) || self.call_uuid.blank? - true - end - end - end -- cgit v1.2.3