summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-03-18 01:54:56 -0400
committerPeter Kozak <spag@golwen.net>2013-03-18 01:54:56 -0400
commitb22b802c80649fb9ee1925cc9ab5a2a959fc89ab (patch)
tree74cd845bd6363b56a06a81c6cfb2cc107f9e2c67
parent208c0bbb9b7b744febbf288f56a3926561cd001b (diff)
parentd007b83d1d6b51caea93b5f08f449db88a930a16 (diff)
Merge branch 'develop' of github.com:amooma/GS5 into develop
-rw-r--r--app/controllers/trigger_controller.rb29
-rw-r--r--app/models/sip_account.rb5
2 files changed, 18 insertions, 16 deletions
diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb
index a858e33..6b58d6a 100644
--- a/app/controllers/trigger_controller.rb
+++ b/app/controllers/trigger_controller.rb
@@ -92,19 +92,26 @@ class TriggerController < ApplicationController
def sip_account_update
sip_account = SipAccount.find(params[:id])
- # TO-DO: Only update the neccessary entries.
- #
- SwitchboardEntry.all.each do |switchboard_entry|
- new_html = ActionController::Base.helpers.escape_javascript(render_to_string("switchboard_entries/_switchboard_entry", :layout => false, :locals => {:switchboard_entry => switchboard_entry}))
- PrivatePub.publish_to("/switchboards/#{switchboard_entry.switchboard.id}", "$('#switchboard_entry_id_" + switchboard_entry.id.to_s + "').replaceWith('#{new_html}');")
- end
+ if sip_account.updated_at < Time.now
- Switchboard.all.each do |switchboard|
- if sip_account.call_legs.where(:sip_account_id => switchboard.user.sip_account_ids).any? ||
- sip_account.b_call_legs.where(:sip_account_id => switchboard.user.sip_account_ids).any?
- new_html = ActionController::Base.helpers.escape_javascript(render_to_string("switchboards/_current_user_dashboard", :layout => false, :locals => {:current_user => switchboard.user}))
- PrivatePub.publish_to("/switchboards/#{switchboard.id}", "$('.dashboard').replaceWith('#{new_html}');")
+ # Push an update to sip_account.switchboard_entries
+ #
+ sip_account.switchboard_entries.each do |switchboard_entry|
+ escaped_switchboard_entry_partial = ActionController::Base.helpers.escape_javascript(render_to_string("switchboard_entries/_switchboard_entry", :layout => false, :locals => {:switchboard_entry => switchboard_entry}))
+ PrivatePub.publish_to("/switchboards/#{switchboard_entry.switchboard.id}", "$('#switchboard_entry_id_" + switchboard_entry.id.to_s + "').replaceWith('#{escaped_switchboard_entry_partial}');")
end
+
+ # Push an update to the needed switchboards
+ #
+ Switchboard.where(:user_id => sip_account.sip_accountable.id).each do |switchboard|
+ if sip_account.call_legs.where(:sip_account_id => switchboard.user.sip_account_ids).any? ||
+ sip_account.b_call_legs.where(:sip_account_id => switchboard.user.sip_account_ids).any?
+ escaped_switchboard_partial = ActionController::Base.helpers.escape_javascript(render_to_string("switchboards/_current_user_dashboard", :layout => false, :locals => {:current_user => switchboard.user}))
+ PrivatePub.publish_to("/switchboards/#{switchboard.id}", "$('.dashboard').replaceWith('#{escaped_switchboard_partial}');")
+ end
+ end
+
+ sip_account.touch
end
render(
diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb
index 50124e9..0c923be 100644
--- a/app/models/sip_account.rb
+++ b/app/models/sip_account.rb
@@ -218,11 +218,6 @@ class SipAccount < ActiveRecord::Base
return states
end
- def non_e164_phone_numbers
- array_of_phone_numbers_as_strings = self.phone_numbers.map{ |phone_number| phone_number.number.to_s }.sort
- self.phone_numbers.where(:number => array_of_phone_numbers_as_strings.select { |phone_number| phone_number[0] != '+' })
- end
-
private
def save_value_of_to_s