summaryrefslogtreecommitdiff
path: root/app/models/call.rb
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-03-07 11:37:03 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-03-07 11:37:03 +0100
commit11f186a118285fbc87a536af26730780a9ad01f5 (patch)
treefe6363b036f60f238916d070b3d0cb0625dd53c8 /app/models/call.rb
parent2b94b16ee1201d15b3b9d66e142df311141a47db (diff)
parent3e19646f46c772e10ed3d7a45e8c974ab23f625b (diff)
Merge branch 'develop'5.1.1
Diffstat (limited to 'app/models/call.rb')
-rw-r--r--app/models/call.rb78
1 files changed, 19 insertions, 59 deletions
diff --git a/app/models/call.rb b/app/models/call.rb
index db6d9d6..8f657fa 100644
--- a/app/models/call.rb
+++ b/app/models/call.rb
@@ -1,30 +1,32 @@
class Call < ActiveRecord::Base
- self.table_name = 'detailed_calls'
+ 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