summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-08-13 15:40:27 +0200
committerPeter Kozak <spag@golwen.net>2013-08-13 15:40:27 +0200
commitda6ecd6f922a2fead39b49db3c2bec1ad9d6bb9f (patch)
tree1f45bf2fe4598b9375573718839ed3f8416abf13
parentf1e25f83da0e24779b95329b8fa96d7cee867557 (diff)
yealink resync added
-rw-r--r--app/models/phone.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/models/phone.rb b/app/models/phone.rb
index 93553a2..f8b7750 100644
--- a/app/models/phone.rb
+++ b/app/models/phone.rb
@@ -116,6 +116,35 @@ class Phone < ActiveRecord::Base
end
return false
+ elsif self.phone_model.manufacturer.ieee_name == 'XIAMEN YEALINK NETWORK TECHNOLOGY CO.,LTD'
+ if !sip_account
+ self.sip_accounts.where(:sip_accountable_type => self.phoneable_type).each do |sip_account_associated|
+ if sip_account_associated.registration
+ sip_account = sip_account_associated
+ break
+ end
+ end
+ end
+
+ if ! sip_account or ! sip_account.registration
+ require 'open-uri'
+ begin
+ if open("http://#{self.ip_address}/cgi-bin/ConfigManApp.com?key=Reboot", :http_basic_authentication=>['admin', self.http_password], :proxy => nil)
+ return true
+ end
+ rescue
+ return false
+ end
+ end
+
+ require 'freeswitch_event'
+ event = FreeswitchEvent.new("NOTIFY")
+ event.add_header("profile", "gemeinschaft")
+ event.add_header("event-string", "check-sync;reboot=#{reboot.to_s}")
+ event.add_header("user", sip_account.auth_name)
+ event.add_header("host", sip_account.sip_domain.host)
+ event.add_header("content-type", "application/simple-message-summary")
+ return event.fire()
end