2018-10-30 16:00:33 +00:00
|
|
|
class SettingAddPlacetel1 < ActiveRecord::Migration[5.1]
|
2018-10-15 09:47:59 +00:00
|
|
|
def change
|
|
|
|
|
|
|
|
# return if it's a new setup
|
2020-08-03 08:35:43 +00:00
|
|
|
return if !Setting.exists?(name: 'system_init_done')
|
2018-10-15 09:47:59 +00:00
|
|
|
|
|
|
|
Setting.create_if_not_exists(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'Placetel integration',
|
|
|
|
name: 'placetel_integration',
|
|
|
|
area: 'Integration::Switch',
|
2018-10-15 09:47:59 +00:00
|
|
|
description: 'Defines if Placetel (http://www.placetel.de) is enabled or not.',
|
2018-12-19 17:31:51 +00:00
|
|
|
options: {
|
2018-10-15 09:47:59 +00:00
|
|
|
form: [
|
|
|
|
{
|
|
|
|
display: '',
|
2018-12-19 17:31:51 +00:00
|
|
|
null: true,
|
|
|
|
name: 'placetel_integration',
|
|
|
|
tag: 'boolean',
|
2018-10-15 09:47:59 +00:00
|
|
|
options: {
|
|
|
|
true => 'yes',
|
|
|
|
false => 'no',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
state: false,
|
2018-10-15 09:47:59 +00:00
|
|
|
preferences: {
|
2018-12-19 17:31:51 +00:00
|
|
|
prio: 1,
|
|
|
|
trigger: ['menu:render', 'cti:reload'],
|
2018-10-15 09:47:59 +00:00
|
|
|
authentication: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
permission: ['admin.integration'],
|
2018-10-15 09:47:59 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
frontend: true
|
2018-10-15 09:47:59 +00:00
|
|
|
)
|
2018-10-30 16:00:33 +00:00
|
|
|
placetel_config = Setting.find_by(name: 'placetel_config')
|
2020-11-05 16:31:00 +00:00
|
|
|
if placetel_config
|
|
|
|
placetel_config.preferences[:cache] = ['placetelGetVoipUsers']
|
|
|
|
placetel_config.save!
|
|
|
|
else
|
2018-10-30 16:00:33 +00:00
|
|
|
Setting.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'Placetel config',
|
|
|
|
name: 'placetel_config',
|
|
|
|
area: 'Integration::Placetel',
|
2018-10-30 16:00:33 +00:00
|
|
|
description: 'Defines the Placetel config.',
|
2018-12-19 17:31:51 +00:00
|
|
|
options: {},
|
|
|
|
state: { 'outbound' => { 'routing_table' => [], 'default_caller_id' => '' }, 'inbound' => { 'block_caller_ids' => [] } },
|
2018-10-30 16:00:33 +00:00
|
|
|
preferences: {
|
2018-12-19 17:31:51 +00:00
|
|
|
prio: 2,
|
2018-10-30 16:00:33 +00:00
|
|
|
permission: ['admin.integration'],
|
2018-12-19 17:31:51 +00:00
|
|
|
cache: ['placetelGetVoipUsers'],
|
2018-10-30 16:00:33 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
frontend: false,
|
2018-10-30 16:00:33 +00:00
|
|
|
)
|
|
|
|
end
|
2018-10-15 09:47:59 +00:00
|
|
|
Setting.create_if_not_exists(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'PLACETEL Token',
|
|
|
|
name: 'placetel_token',
|
|
|
|
area: 'Integration::Placetel',
|
2018-10-15 09:47:59 +00:00
|
|
|
description: 'Token for placetel.',
|
2018-12-19 17:31:51 +00:00
|
|
|
options: {
|
2018-10-15 09:47:59 +00:00
|
|
|
form: [
|
|
|
|
{
|
|
|
|
display: '',
|
2018-12-19 17:31:51 +00:00
|
|
|
null: false,
|
|
|
|
name: 'placetel_token',
|
|
|
|
tag: 'input',
|
2018-10-15 09:47:59 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
state: ENV['PLACETEL_TOKEN'] || SecureRandom.urlsafe_base64(20),
|
2018-10-15 09:47:59 +00:00
|
|
|
preferences: {
|
|
|
|
permission: ['admin.integration'],
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
frontend: false
|
2018-10-15 09:47:59 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|