summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-03-19 01:57:37 -0400
committerPeter Kozak <spag@golwen.net>2013-03-19 01:57:37 -0400
commite6e893009b763ac8013088a9f8d041e5e43c0bd3 (patch)
treed681f58b1d7f35f61c0827f36ef9f2ba8b3451b1 /app/models
parent2470988e06ff861c92d3dc833755f4b262798a12 (diff)
retrieve conference data
Diffstat (limited to 'app/models')
-rw-r--r--app/models/conference.rb25
1 files changed, 21 insertions, 4 deletions
diff --git a/app/models/conference.rb b/app/models/conference.rb
index 880b958..a9d6708 100644
--- a/app/models/conference.rb
+++ b/app/models/conference.rb
@@ -54,18 +54,35 @@ class Conference < ActiveRecord::Base
require 'freeswitch_event'
result = FreeswitchAPI.api_result(FreeswitchAPI.api('conference', "conference#{self.id}", 'xml_list'))
if result =~ /^\<\?xml/
- return Hash.from_xml(result)
+ data = Hash.from_xml(result)
+ if data
+ return data.fetch('conferences',{}).fetch('conference',{})
+ end
end
return nil
end
- def list_members
- data = self.list_conference
+ def list_members(data=self.list_conference())
if data.blank?
return {}
end
- return data.fetch('conferences',{}).fetch('conference',{}).fetch('members',{}).fetch('member',{})
+ members = data.fetch('members',{}).fetch('member',{})
+ if members.class != Array
+ members = [members]
+ end
+
+ members.each_with_index do |member, index|
+ members[index][:call] = Call.where(:uuid => member['uuid']).first
+ if !members[index][:call]
+ members[index][:call] = Call.where(:b_uuid => member['uuid']).first
+ if members[index][:call]
+ members[index][:call_bleg] = true;
+ end
+ end
+ end
+
+ return members;
end