From f5cddb733550b16851a36b50f9b3f861c1f0de89 Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 29 Jan 2013 11:06:46 +0100 Subject: profile --- app/models/gateway_setting.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app/models') diff --git a/app/models/gateway_setting.rb b/app/models/gateway_setting.rb index e3eaadb..381dde5 100644 --- a/app/models/gateway_setting.rb +++ b/app/models/gateway_setting.rb @@ -10,6 +10,7 @@ class GatewaySetting < ActiveRecord::Base 'auth_source' => 'String', 'auth_pattern' => 'String', 'number_source' => 'String', + 'profile' => 'String', }, 'xmpp' => { 'server' => 'String', -- cgit v1.2.3 From d4a664a0495bd183b16a239aeb4c342e1ca739fa Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 30 Jan 2013 15:59:52 +0100 Subject: select route endpoint --- app/models/call_route.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/models') diff --git a/app/models/call_route.rb b/app/models/call_route.rb index b4496ab..1c3f70a 100644 --- a/app/models/call_route.rb +++ b/app/models/call_route.rb @@ -239,6 +239,10 @@ class CallRoute < ActiveRecord::Base end end + def endpoint_str + "#{endpoint_type}=#{endpoint_id}" + end + def endpoint if self.endpoint_id.to_i > 0 begin -- cgit v1.2.3 From 68f0f677c5cba6775622d0e50c4315e6361ff5c9 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Thu, 31 Jan 2013 12:26:47 +0100 Subject: First test setup for the backup. --- app/models/gs5_backup.rb | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 app/models/gs5_backup.rb (limited to 'app/models') diff --git a/app/models/gs5_backup.rb b/app/models/gs5_backup.rb new file mode 100644 index 0000000..928245f --- /dev/null +++ b/app/models/gs5_backup.rb @@ -0,0 +1,53 @@ +# encoding: utf-8 + +## +# Backup Generated: gs5_backup +# Once configured, you can run the backup with the following command: +# +# $ backup perform -t gs5_backup [-c ] +# +Backup::Model.new(:gs5_backup, 'GS5 backup') do + ## + # Split [Splitter] + # + # Split the backup file in to chunks of 250 megabytes + # if the backup file size exceeds 250 megabytes + # + split_into_chunks_of 640 + + ## + # MySQL [Database] + # + database MySQL do |db| + # To dump all databases, set `db.name = :all` (or leave blank) + db.name = system_odbc_configuration['gemeinschaft']['DATABASE'] + db.username = system_odbc_configuration['gemeinschaft']['USER'] + db.password = system_odbc_configuration['gemeinschaft']['PASSWORD'] + db.host = "localhost" + db.port = 3306 + db.socket = "/tmp/mysql.sock" + # Note: when using `skip_tables` with the `db.name = :all` option, + # table names should be prefixed with a database name. + # e.g. ["db_name.table_to_skip", ...] + db.skip_tables = ["skip", "these", "tables"] + db.only_tables = ["only", "these" "tables"] + db.additional_options = ["--quick", "--single-transaction"] + # Optional: Use to set the location of this utility + # if it cannot be found by name in your $PATH + # db.mysqldump_utility = "/opt/local/bin/mysqldump" + end + + ## + # Local (Copy) [Storage] + # + store_with Local do |local| + local.path = "/var/backups/gs5" + local.keep = 5 + end + + ## + # Gzip [Compressor] + # + compress_with Gzip + +end -- cgit v1.2.3 From d3af3a902ef110b50abcc599962bc856eefe4428 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Thu, 31 Jan 2013 14:42:20 +0100 Subject: Fixed the backup config. --- app/models/gs5_backup.rb | 53 ------------------------------------------------ 1 file changed, 53 deletions(-) delete mode 100644 app/models/gs5_backup.rb (limited to 'app/models') diff --git a/app/models/gs5_backup.rb b/app/models/gs5_backup.rb deleted file mode 100644 index 928245f..0000000 --- a/app/models/gs5_backup.rb +++ /dev/null @@ -1,53 +0,0 @@ -# encoding: utf-8 - -## -# Backup Generated: gs5_backup -# Once configured, you can run the backup with the following command: -# -# $ backup perform -t gs5_backup [-c ] -# -Backup::Model.new(:gs5_backup, 'GS5 backup') do - ## - # Split [Splitter] - # - # Split the backup file in to chunks of 250 megabytes - # if the backup file size exceeds 250 megabytes - # - split_into_chunks_of 640 - - ## - # MySQL [Database] - # - database MySQL do |db| - # To dump all databases, set `db.name = :all` (or leave blank) - db.name = system_odbc_configuration['gemeinschaft']['DATABASE'] - db.username = system_odbc_configuration['gemeinschaft']['USER'] - db.password = system_odbc_configuration['gemeinschaft']['PASSWORD'] - db.host = "localhost" - db.port = 3306 - db.socket = "/tmp/mysql.sock" - # Note: when using `skip_tables` with the `db.name = :all` option, - # table names should be prefixed with a database name. - # e.g. ["db_name.table_to_skip", ...] - db.skip_tables = ["skip", "these", "tables"] - db.only_tables = ["only", "these" "tables"] - db.additional_options = ["--quick", "--single-transaction"] - # Optional: Use to set the location of this utility - # if it cannot be found by name in your $PATH - # db.mysqldump_utility = "/opt/local/bin/mysqldump" - end - - ## - # Local (Copy) [Storage] - # - store_with Local do |local| - local.path = "/var/backups/gs5" - local.keep = 5 - end - - ## - # Gzip [Compressor] - # - compress_with Gzip - -end -- cgit v1.2.3 From 66a53a49705c269d73f9d51bb0d4a51283049c71 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 4 Feb 2013 13:00:45 +0100 Subject: Changed softkey table to be sortable. #150 --- app/models/sip_account.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models') diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb index 444eb12..9ba1f8b 100644 --- a/app/models/sip_account.rb +++ b/app/models/sip_account.rb @@ -21,7 +21,7 @@ class SipAccount < ActiveRecord::Base belongs_to :tenant belongs_to :sip_domain - has_many :softkeys, :dependent => :destroy + has_many :softkeys, :dependent => :destroy, :order => :position has_many :voicemail_messages, :foreign_key => 'username', :primary_key => 'auth_name' -- cgit v1.2.3 From bb8168c33f9501fe877345a7bbc7b7f7b64cdfc7 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 5 Feb 2013 12:40:42 +0100 Subject: Added a BackupJob scaffold. --- app/models/backup_job.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 app/models/backup_job.rb (limited to 'app/models') diff --git a/app/models/backup_job.rb b/app/models/backup_job.rb new file mode 100644 index 0000000..d579b79 --- /dev/null +++ b/app/models/backup_job.rb @@ -0,0 +1,14 @@ +class BackupJob < ActiveRecord::Base + attr_accessible :started_at, :finished_at, :state, :directory, :size_of_the_backup + + after_save :start_the_backup + + private + def start_the_backup + if self.finished_at.nil? + sh "backup perform --trigger gs5 --config_file #{Rails.root.join('config','backup.rb')}" + self.finished_at = Time.now + self.save + end + end +end -- cgit v1.2.3 From c7389cb6f1a305bc7e5cfefd9548c1e1bf7b6018 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 5 Feb 2013 13:44:10 +0100 Subject: Bugfix --- app/models/backup_job.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/models') diff --git a/app/models/backup_job.rb b/app/models/backup_job.rb index d579b79..5149553 100644 --- a/app/models/backup_job.rb +++ b/app/models/backup_job.rb @@ -1,12 +1,12 @@ class BackupJob < ActiveRecord::Base attr_accessible :started_at, :finished_at, :state, :directory, :size_of_the_backup - after_save :start_the_backup + after_create :start_the_backup private def start_the_backup if self.finished_at.nil? - sh "backup perform --trigger gs5 --config_file #{Rails.root.join('config','backup.rb')}" + system "backup perform --trigger gs5 --config_file #{Rails.root.join('config','backup.rb')}" self.finished_at = Time.now self.save end -- cgit v1.2.3 From 75b36967fed9db8268391ac10b02f5c0870c32ca Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 5 Feb 2013 15:11:56 +0100 Subject: Finetuning backup. --- app/models/ability.rb | 4 ++++ app/models/backup_job.rb | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'app/models') diff --git a/app/models/ability.rb b/app/models/ability.rb index 0d13dab..01f26aa 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -64,6 +64,10 @@ class Ability # cannot [:edit, :update], FaxDocument + # Backups can't be edited + # + cannot [:edit, :update], BackupJob + # Can manage GsNodes # can :manage, GsNode diff --git a/app/models/backup_job.rb b/app/models/backup_job.rb index 5149553..b0a588f 100644 --- a/app/models/backup_job.rb +++ b/app/models/backup_job.rb @@ -6,8 +6,9 @@ class BackupJob < ActiveRecord::Base private def start_the_backup if self.finished_at.nil? - system "backup perform --trigger gs5 --config_file #{Rails.root.join('config','backup.rb')}" + system "backup perform --trigger GS5 --config_file #{Rails.root.join('config','backup.rb')}" self.finished_at = Time.now + self.status = 'done' self.save end end -- cgit v1.2.3 From b1f9f3b2c39d31d0621da36420318406f33a1f92 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 5 Feb 2013 16:21:02 +0100 Subject: DelayedJob table upgrade. --- app/models/backup_job.rb | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'app/models') diff --git a/app/models/backup_job.rb b/app/models/backup_job.rb index b0a588f..a90726c 100644 --- a/app/models/backup_job.rb +++ b/app/models/backup_job.rb @@ -1,14 +1,25 @@ class BackupJob < ActiveRecord::Base attr_accessible :started_at, :finished_at, :state, :directory, :size_of_the_backup - after_create :start_the_backup + after_create :initiate_backup private - def start_the_backup - if self.finished_at.nil? + def initiate_backup + self.delay.make_a_backup + end + + def make_a_backup + if self.finished_at.nil? + original_directories = Dir.glob('/var/backups/GS5/*') system "backup perform --trigger GS5 --config_file #{Rails.root.join('config','backup.rb')}" - self.finished_at = Time.now - self.status = 'done' + self.directory = (Dir.glob('/var/backups/GS5/*') - original_directories).first + if self.directory.blank? + self.state = 'unsuccessful' + else + self.size_of_the_backup = (`du -hs #{new_directory}`).split(/\t/).first + self.finished_at = Time.now + self.state = 'successful' + end self.save end end -- cgit v1.2.3 From 3edd6e58ea3f5d25068ea9d47f639ae89e5f2c0c Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 6 Feb 2013 11:07:04 +0100 Subject: Improved the backup. --- app/models/backup_job.rb | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'app/models') diff --git a/app/models/backup_job.rb b/app/models/backup_job.rb index a90726c..c9bde2b 100644 --- a/app/models/backup_job.rb +++ b/app/models/backup_job.rb @@ -1,26 +1,43 @@ class BackupJob < ActiveRecord::Base attr_accessible :started_at, :finished_at, :state, :directory, :size_of_the_backup + before_create :set_state_to_queued after_create :initiate_backup + after_destroy :delete_the_backup_directory private + def set_state_to_queued + self.state = 'queued' + self.started_at = Time.now + end + def initiate_backup self.delay.make_a_backup end def make_a_backup - if self.finished_at.nil? + if self.finished_at.nil? && self.state == 'queued' + self.state = 'running' + self.save original_directories = Dir.glob('/var/backups/GS5/*') system "backup perform --trigger GS5 --config_file #{Rails.root.join('config','backup.rb')}" self.directory = (Dir.glob('/var/backups/GS5/*') - original_directories).first if self.directory.blank? - self.state = 'unsuccessful' + self.state = 'failed' else - self.size_of_the_backup = (`du -hs #{new_directory}`).split(/\t/).first + file = File::Stat.new(self.directory) + self.size_of_the_backup = file.size self.finished_at = Time.now self.state = 'successful' end self.save end end + + def delete_the_backup_directory + if !self.directory.blank? + require 'fileutils' + FileUtils.rm_rf self.directory + end + end end -- cgit v1.2.3 From 07d49f54067cfb8666f650323c7ffefe1e860b24 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 6 Feb 2013 16:03:43 +0100 Subject: Use CarrierWave to store the backup file. --- app/models/backup_job.rb | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'app/models') diff --git a/app/models/backup_job.rb b/app/models/backup_job.rb index c9bde2b..c1f12e4 100644 --- a/app/models/backup_job.rb +++ b/app/models/backup_job.rb @@ -1,6 +1,8 @@ class BackupJob < ActiveRecord::Base attr_accessible :started_at, :finished_at, :state, :directory, :size_of_the_backup + mount_uploader :backup_file, BackupFileUploader + before_create :set_state_to_queued after_create :initiate_backup after_destroy :delete_the_backup_directory @@ -16,17 +18,26 @@ class BackupJob < ActiveRecord::Base end def make_a_backup + backup_directory = '/var/backups/GS5' + backup_name_prefix = 'GS5-backup-' if self.finished_at.nil? && self.state == 'queued' self.state = 'running' self.save - original_directories = Dir.glob('/var/backups/GS5/*') + original_directories = Dir.glob("#{backup_directory}/*") system "backup perform --trigger GS5 --config_file #{Rails.root.join('config','backup.rb')}" - self.directory = (Dir.glob('/var/backups/GS5/*') - original_directories).first - if self.directory.blank? + tmp_backup_directory = (Dir.glob("#{backup_directory}/*") - original_directories).first + if tmp_backup_directory.blank? self.state = 'failed' else - file = File::Stat.new(self.directory) + system "cd #{backup_directory} && tar czf #{backup_name_prefix}#{tmp_backup_directory}.tar.gz #{tmp_backup_directory}" + require 'fileutils' + FileUtils.rm_rf tmp_backup_directory + file = File::Stat.new("#{backup_directory}/#{backup_name_prefix}#{tmp_backup_directory}.tar.gz") + self.size_of_the_backup = file.size + + self.backup_file = File.open("#{backup_directory}/#{backup_name_prefix}#{tmp_backup_directory}.tar.gz") + self.finished_at = Time.now self.state = 'successful' end @@ -35,9 +46,9 @@ class BackupJob < ActiveRecord::Base end def delete_the_backup_directory - if !self.directory.blank? - require 'fileutils' - FileUtils.rm_rf self.directory - end + # if !tmp_backup_directory.blank? + # require 'fileutils' + # FileUtils.rm_rf tmp_backup_directory + # end end end -- cgit v1.2.3 From 72f100c680ddcf9c36448ae3ee367eab19052adc Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Thu, 7 Feb 2013 09:27:43 +0100 Subject: Use CarrierWave to store the tar.gz. Removed size_of_the_backup attribute. --- app/models/backup_job.rb | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'app/models') diff --git a/app/models/backup_job.rb b/app/models/backup_job.rb index c1f12e4..78d95a7 100644 --- a/app/models/backup_job.rb +++ b/app/models/backup_job.rb @@ -5,7 +5,6 @@ class BackupJob < ActiveRecord::Base before_create :set_state_to_queued after_create :initiate_backup - after_destroy :delete_the_backup_directory private def set_state_to_queued @@ -29,14 +28,14 @@ class BackupJob < ActiveRecord::Base if tmp_backup_directory.blank? self.state = 'failed' else - system "cd #{backup_directory} && tar czf #{backup_name_prefix}#{tmp_backup_directory}.tar.gz #{tmp_backup_directory}" + system "cd #{backup_directory} && tar czf #{backup_name_prefix}#{File.basename(tmp_backup_directory)}.tar.gz #{File.basename(tmp_backup_directory)}" require 'fileutils' FileUtils.rm_rf tmp_backup_directory - file = File::Stat.new("#{backup_directory}/#{backup_name_prefix}#{tmp_backup_directory}.tar.gz") + file = File::Stat.new("#{backup_directory}/#{backup_name_prefix}#{File.basename(tmp_backup_directory)}.tar.gz") - self.size_of_the_backup = file.size + self.directory = File.basename(tmp_backup_directory) - self.backup_file = File.open("#{backup_directory}/#{backup_name_prefix}#{tmp_backup_directory}.tar.gz") + self.backup_file = File.open("#{backup_directory}/#{backup_name_prefix}#{File.basename(tmp_backup_directory)}.tar.gz") self.finished_at = Time.now self.state = 'successful' @@ -45,10 +44,4 @@ class BackupJob < ActiveRecord::Base end end - def delete_the_backup_directory - # if !tmp_backup_directory.blank? - # require 'fileutils' - # FileUtils.rm_rf tmp_backup_directory - # end - end end -- cgit v1.2.3 From 5e8237d8a8cf17009189fcf0259fb1b8a50ab429 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Thu, 7 Feb 2013 10:49:01 +0100 Subject: Bugfixes. --- app/models/backup_job.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models') diff --git a/app/models/backup_job.rb b/app/models/backup_job.rb index 78d95a7..8bb7959 100644 --- a/app/models/backup_job.rb +++ b/app/models/backup_job.rb @@ -1,5 +1,5 @@ class BackupJob < ActiveRecord::Base - attr_accessible :started_at, :finished_at, :state, :directory, :size_of_the_backup + attr_accessible :started_at, :finished_at, :state, :directory mount_uploader :backup_file, BackupFileUploader -- cgit v1.2.3 From 515dcaf96c05e4b5d6aaaf4ff1e438ebf9a3c56a Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Thu, 7 Feb 2013 14:30:21 +0100 Subject: Breadcrumbs for BackupJobs. --- app/models/backup_job.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/models') diff --git a/app/models/backup_job.rb b/app/models/backup_job.rb index 8bb7959..96574a7 100644 --- a/app/models/backup_job.rb +++ b/app/models/backup_job.rb @@ -6,6 +6,10 @@ class BackupJob < ActiveRecord::Base before_create :set_state_to_queued after_create :initiate_backup + def to_s + self.started_at.to_s + end + private def set_state_to_queued self.state = 'queued' -- cgit v1.2.3 From 50f1c25d6ae641e48d29cc4a6742dd12ce60d4a9 Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 7 Feb 2013 15:13:14 +0100 Subject: dtmf routing table added --- app/models/call_route.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models') diff --git a/app/models/call_route.rb b/app/models/call_route.rb index 1c3f70a..6e0dcab 100644 --- a/app/models/call_route.rb +++ b/app/models/call_route.rb @@ -2,7 +2,7 @@ class CallRoute < ActiveRecord::Base # https://github.com/rails/strong_parameters include ActiveModel::ForbiddenAttributesProtection - ROUTING_TABLES = ['prerouting', 'outbound', 'inbound'] + ROUTING_TABLES = ['prerouting', 'outbound', 'inbound', 'dtmf'] has_many :route_elements, :dependent => :destroy -- cgit v1.2.3 From 9e723519982c3b442aa90f3728bfddd4025d4a69 Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 8 Feb 2013 10:41:18 +0100 Subject: softkey-call_forward relation polymorphic --- app/models/call_forward.rb | 2 +- app/models/softkey.rb | 19 ++++++------------- 2 files changed, 7 insertions(+), 14 deletions(-) (limited to 'app/models') diff --git a/app/models/call_forward.rb b/app/models/call_forward.rb index 8a8d1df..c668993 100644 --- a/app/models/call_forward.rb +++ b/app/models/call_forward.rb @@ -145,7 +145,7 @@ class CallForward < ActiveRecord::Base softkey_function_deactivated = SoftkeyFunction.find_by_name('deactivated') self.softkeys.each do |softkey| if softkey.softkey_function_id != softkey_function_deactivated.id - softkey.update_attributes(:call_forward_id => nil, :softkey_function_id => softkey_function_deactivated.id) + softkey.update_attributes(:softkeyable_id => nil, :softkeyable_type => nil, :softkey_function_id => softkey_function_deactivated.id) end end end diff --git a/app/models/softkey.rb b/app/models/softkey.rb index a709036..f038acd 100644 --- a/app/models/softkey.rb +++ b/app/models/softkey.rb @@ -1,13 +1,11 @@ class Softkey < ActiveRecord::Base - attr_accessible :softkey_function_id, :number, :label, :call_forward_id, :uuid + attr_accessible :softkey_function_id, :number, :label, :uuid, :softkeyable_type, :softkeyable_id belongs_to :sip_account belongs_to :softkey_function - belongs_to :call_forward + belongs_to :softkeyable, :polymorphic => true - # Any CallForward BLF must have a valid softkey_call_forward_id. - # - validates_presence_of :call_forward_id, :if => Proc.new{ |softkey| self.softkey_function_id != nil && + validates_presence_of :softkeyable_id, :if => Proc.new{ |softkey| self.softkey_function_id != nil && self.softkey_function_id == SoftkeyFunction.find_by_name('call_forwarding').try(:id) } # These functions need a number to act. @@ -21,7 +19,6 @@ class Softkey < ActiveRecord::Base acts_as_list :scope => :sip_account before_validation :clean_up_and_leave_only_values_which_make_sense_for_the_current_softkey_function_id - after_validation :save_function_name_in_function, :if => Proc.new{ |softkey| self.call_forward_id.blank? } after_save :resync_phone after_destroy :resync_phone @@ -52,7 +49,7 @@ class Softkey < ActiveRecord::Base def to_s if (['call_forwarding'].include?(self.softkey_function.name)) - "#{self.call_forward}" + "#{self.softkeyable}" else if ['log_out', 'log_in'].include?(self.softkey_function.name) I18n.t("softkeys.functions.#{self.softkey_function.name}") @@ -78,18 +75,14 @@ class Softkey < ActiveRecord::Base end private - - def save_function_name_in_function - self.function = self.softkey_function.name - end - # Make sure that no number is set when there is no need for one. # And make sure that there is no CallForward connected when not needed. # def clean_up_and_leave_only_values_which_make_sense_for_the_current_softkey_function_id if self.softkey_function_id != nil if ['blf','speed_dial','dtmf','conference'].include?(self.softkey_function.name) - self.call_forward_id = nil + self.softkeyable_id = nil + self.softkeyable_type = nil end if ['call_forwarding'].include?(self.softkey_function.name) self.number = nil -- cgit v1.2.3 From 901eb1ce8bdbfcd85678e06086cce5a0d7b50123 Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 8 Feb 2013 11:51:55 +0100 Subject: set softkeyable --- app/models/softkey.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app/models') diff --git a/app/models/softkey.rb b/app/models/softkey.rb index f038acd..3ae7e95 100644 --- a/app/models/softkey.rb +++ b/app/models/softkey.rb @@ -85,6 +85,7 @@ class Softkey < ActiveRecord::Base self.softkeyable_type = nil end if ['call_forwarding'].include?(self.softkey_function.name) + self.softkeyable = CallForward.where(:id => self.softkeyable_id).first self.number = nil end end -- cgit v1.2.3 From af5179a4a59bc21467448f292c752082dd8927b8 Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 8 Feb 2013 12:06:16 +0100 Subject: set softkeyable --- app/models/softkey.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'app/models') diff --git a/app/models/softkey.rb b/app/models/softkey.rb index 3ae7e95..83c88ab 100644 --- a/app/models/softkey.rb +++ b/app/models/softkey.rb @@ -79,14 +79,18 @@ class Softkey < ActiveRecord::Base # And make sure that there is no CallForward connected when not needed. # def clean_up_and_leave_only_values_which_make_sense_for_the_current_softkey_function_id - if self.softkey_function_id != nil - if ['blf','speed_dial','dtmf','conference'].include?(self.softkey_function.name) - self.softkeyable_id = nil - self.softkeyable_type = nil - end - if ['call_forwarding'].include?(self.softkey_function.name) + if self.softkey_function_id != nil + case self.softkey_function.name + when 'blf' + self.softkeyable = PhoneNumber.where(:number => self.number, :phone_numberable_type => 'SipAccount').first.try(:phone_numberable) + when 'conference' + self.softkeyable = PhoneNumber.where(:number => self.number, :phone_numberable_type => 'Conference').first.try(:phone_numberable) + when 'call_forwarding' self.softkeyable = CallForward.where(:id => self.softkeyable_id).first self.number = nil + else + self.softkeyable_id = nil + self.softkeyable_type = nil end end end -- cgit v1.2.3 From db31cc867b1e99b4d388b1835dbaec2ad845c29a Mon Sep 17 00:00:00 2001 From: spag Date: Sat, 9 Feb 2013 09:50:54 +0100 Subject: gateway has routes --- app/models/gateway.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app/models') diff --git a/app/models/gateway.rb b/app/models/gateway.rb index a8df41f..eea1e33 100644 --- a/app/models/gateway.rb +++ b/app/models/gateway.rb @@ -5,6 +5,7 @@ class Gateway < ActiveRecord::Base has_many :gateway_settings, :dependent => :destroy has_many :gateway_parameters, :dependent => :destroy + has_many :call_routes, :as => :endpoint, :dependent => :nullify validates :name, :presence => true, -- cgit v1.2.3 From 42a8e4808e343975042730ab3847303184d73b92 Mon Sep 17 00:00:00 2001 From: spag Date: Sat, 9 Feb 2013 10:05:00 +0100 Subject: identifier added --- app/models/gateway.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/models') diff --git a/app/models/gateway.rb b/app/models/gateway.rb index eea1e33..2f17b57 100644 --- a/app/models/gateway.rb +++ b/app/models/gateway.rb @@ -1,5 +1,6 @@ class Gateway < ActiveRecord::Base TECHNOLOGIES = ['sip', 'xmpp'] + GATEWAY_PREFIX = 'gateway' attr_accessible :name, :technology, :inbound, :outbound, :description @@ -22,6 +23,10 @@ class Gateway < ActiveRecord::Base name end + def identifier + "#{GATEWAY_PREFIX}#{self.id}" + end + private def downcase_technology self.technology = self.technology.downcase if !self.technology.blank? -- cgit v1.2.3 From 4c9cc92c0a49ec34c8bf00e31d1710450fb533fa Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 10 Feb 2013 08:09:05 +0000 Subject: firewall blacklist model added --- app/models/intruder.rb | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 app/models/intruder.rb (limited to 'app/models') diff --git a/app/models/intruder.rb b/app/models/intruder.rb new file mode 100644 index 0000000..192d64d --- /dev/null +++ b/app/models/intruder.rb @@ -0,0 +1,3 @@ +class Intruder < ActiveRecord::Base + attr_accessible :list_type, :key, :points, :bans, :ban_last, :ban_end, :contact_ip, :contact_port, :contact_count, :contact_last, :contacts_per_second, :contacts_per_second_max, :user_agent, :to_user, :comment +end -- cgit v1.2.3 From 70a6449fa176059e603a16a21699c8f5c60765e1 Mon Sep 17 00:00:00 2001 From: spag Date: Sun, 10 Feb 2013 16:59:57 +0100 Subject: intruder updated --- app/models/intruder.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'app/models') diff --git a/app/models/intruder.rb b/app/models/intruder.rb index 192d64d..c013ee8 100644 --- a/app/models/intruder.rb +++ b/app/models/intruder.rb @@ -1,3 +1,26 @@ class Intruder < ActiveRecord::Base attr_accessible :list_type, :key, :points, :bans, :ban_last, :ban_end, :contact_ip, :contact_port, :contact_count, :contact_last, :contacts_per_second, :contacts_per_second_max, :user_agent, :to_user, :comment + + LIST_TYPES = ['blacklist', 'whitelist'] + + validates :list_type, + :presence => true, + :inclusion => { :in => LIST_TYPES } + + validates :key, + :presence => true, + :uniqueness => true + + validates :contact_ip, + :presence => true, + :uniqueness => true + + before_validation :set_key_if_empty + + private + def set_key_if_empty + if self.key.blank? + self.key = self.contact_ip + end + end end -- cgit v1.2.3 From 7332f8e0b13ad4b5999b443b7baf36574b6d9593 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 11 Feb 2013 10:07:33 +0100 Subject: call model rewrite --- app/models/call.rb | 70 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 53 insertions(+), 17 deletions(-) (limited to 'app/models') diff --git a/app/models/call.rb b/app/models/call.rb index 57961ec..c0f0f08 100644 --- a/app/models/call.rb +++ b/app/models/call.rb @@ -1,36 +1,72 @@ class Call < ActiveRecord::Base - self.table_name = 'channels' + self.table_name = 'detailed_calls' self.primary_key = 'uuid' - # Makes sure that this is a readonly model. def readonly? return true end - - # Prevent objects from being destroyed - def before_destroy - raise ActiveRecord::ReadOnlyRecord - end - # Prevent objects from being deleted - def self.delete_all - raise ActiveRecord::ReadOnlyRecord + def destroy + return self.delete end - # Prevent objects from being deleted def delete - raise ActiveRecord::ReadOnlyRecord + require 'freeswitch_event' + return FreeswitchAPI.execute('uuid_kill', self.uuid, true); end def sip_account - auth_name = self.name.match('^.+[/:](.+)@.+$') - if auth_name && ! auth_name[1].blank? - return SipAccount.where(:auth_name => auth_name[1]).first + result = self.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 kill + 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 + end + require 'freeswitch_event' - return FreeswitchAPI.execute('uuid_kill', self.uuid, true); + result = FreeswitchAPI.channel_variable_get(channel_uuid, variable_name); + + if result == '_undef_' + return nil + end + + return result + end + + def get_variable(variable_name) + return get_variable_from_uuid(self.uuid, variable_name); + end + + def get_variable_bleg(variable_name) + 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 -- cgit v1.2.3 From 62ac01a8ea536718734bd911fc3642c0bd8b6bc7 Mon Sep 17 00:00:00 2001 From: spag Date: Mon, 11 Feb 2013 13:04:05 +0100 Subject: ipwhois added --- app/models/intruder.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/models') diff --git a/app/models/intruder.rb b/app/models/intruder.rb index c013ee8..db14bf8 100644 --- a/app/models/intruder.rb +++ b/app/models/intruder.rb @@ -17,6 +17,17 @@ class Intruder < ActiveRecord::Base before_validation :set_key_if_empty + + def whois + if ! self.contact_ip.blank? + begin + return Whois.whois(self.contact_ip) + rescue + return nil + end + end + end + private def set_key_if_empty if self.key.blank? -- cgit v1.2.3 From 29db90c2c8a9a6a3087e77eae8615ddf0049087b Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 11 Feb 2013 14:40:38 +0100 Subject: Deleted PrivatePub stuff. --- app/models/ability.rb | 4 ---- 1 file changed, 4 deletions(-) (limited to 'app/models') diff --git a/app/models/ability.rb b/app/models/ability.rb index 01f26aa..4ec64b1 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -56,10 +56,6 @@ class Ability can :read, PhoneBookEntry, :phone_book => { :id => user_group.phone_book_ids } end - # SystemMessages - # - cannot [:destroy, :edit, :update], SystemMessage - # A FacDocument can't be changed # cannot [:edit, :update], FaxDocument -- cgit v1.2.3 From ca8121930d7e75b9f6bac08591c6ffea3ca1fea1 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 11 Feb 2013 14:42:22 +0100 Subject: Removed PrivatePub stuff. --- app/models/ability.rb | 4 ---- app/models/system_message.rb | 7 ------- 2 files changed, 11 deletions(-) delete mode 100644 app/models/system_message.rb (limited to 'app/models') diff --git a/app/models/ability.rb b/app/models/ability.rb index 4ec64b1..4c0844c 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -156,10 +156,6 @@ class Ability # can :manage, CallForward, :phone_number_id => user.phone_number_ids - # SystemMessages - # - can :read, SystemMessage, :user_id => user.id - # SoftkeyFunctions # can :read, SoftkeyFunction diff --git a/app/models/system_message.rb b/app/models/system_message.rb deleted file mode 100644 index 0d9e862..0000000 --- a/app/models/system_message.rb +++ /dev/null @@ -1,7 +0,0 @@ -class SystemMessage < ActiveRecord::Base - attr_accessible :content - - belongs_to :user - - validates_presence_of :content -end -- cgit v1.2.3 From f8f35f666613eff24d3988bda1a22cc40ef2ab30 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 12 Feb 2013 13:26:30 +0100 Subject: Make the call_elements table sortable by drag and drop. --- app/models/call_route.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models') diff --git a/app/models/call_route.rb b/app/models/call_route.rb index 6e0dcab..8bc811a 100644 --- a/app/models/call_route.rb +++ b/app/models/call_route.rb @@ -4,7 +4,7 @@ class CallRoute < ActiveRecord::Base ROUTING_TABLES = ['prerouting', 'outbound', 'inbound', 'dtmf'] - has_many :route_elements, :dependent => :destroy + has_many :route_elements, :dependent => :destroy, :order => :position validates :name, :presence => true -- cgit v1.2.3