diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-02-27 12:22:29 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-02-27 12:22:29 +0100 |
commit | 67c1a0a951403a546250ea860a3e3d199cae2fce (patch) | |
tree | f86ec6cedf081a1a57005eca1661e9bead34e4de /app/models/call.rb | |
parent | 5d8ce5f4775ac8bc5f523964e6e36f63ff3c4683 (diff) | |
parent | 211f558a86ae30cdd5b392ab1376e1393f97e22c (diff) |
Merge branch 'develop'5.1-beta6
Diffstat (limited to 'app/models/call.rb')
-rw-r--r-- | app/models/call.rb | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/app/models/call.rb b/app/models/call.rb index c0f0f08..db6d9d6 100644 --- a/app/models/call.rb +++ b/app/models/call.rb @@ -1,9 +1,31 @@ class Call < ActiveRecord::Base self.table_name = 'detailed_calls' self.primary_key = 'uuid' + + attr_writer :sip_account_id + + validates :dest, + :presence => true - def readonly? - return 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 + end + + def save(attributes=nil) + + end + + def call(number=nil) + if @sip_account && self.dest + return @sip_account.call(self.dest) + end + return false end def destroy @@ -15,15 +37,25 @@ 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 - return SipAccount.where(:auth_name => result[1], :sip_domain_id => domain.id).first + @sip_account = SipAccount.where(:auth_name => result[1], :sip_domain_id => domain.id).first end end + + return @sip_account end def sip_account_bleg @@ -69,4 +101,5 @@ class Call < ActiveRecord::Base true end end + end |