From da6ecd6f922a2fead39b49db3c2bec1ad9d6bb9f Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 13 Aug 2013 15:40:27 +0200 Subject: yealink resync added --- app/models/phone.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) 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 -- cgit v1.2.3