2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2018-08-09 21:06:34 +00:00
|
|
|
class CtiGenericApi < ActiveRecord::Migration[5.1]
|
2018-05-28 23:45:29 +00:00
|
|
|
def up
|
|
|
|
|
|
|
|
# return if it's a new setup
|
2020-08-03 08:35:43 +00:00
|
|
|
return if !Setting.exists?(name: 'system_init_done')
|
2018-05-28 23:45:29 +00:00
|
|
|
|
|
|
|
Setting.create_if_not_exists(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'cti integration',
|
|
|
|
name: 'cti_integration',
|
|
|
|
area: 'Integration::Switch',
|
2018-05-28 23:45:29 +00:00
|
|
|
description: 'Defines if generic CTI is enabled or not.',
|
2018-12-19 17:31:51 +00:00
|
|
|
options: {
|
2018-05-28 23:45:29 +00:00
|
|
|
form: [
|
|
|
|
{
|
|
|
|
display: '',
|
2018-12-19 17:31:51 +00:00
|
|
|
null: true,
|
|
|
|
name: 'cti_integration',
|
|
|
|
tag: 'boolean',
|
2018-05-28 23:45:29 +00:00
|
|
|
options: {
|
|
|
|
true => 'yes',
|
|
|
|
false => 'no',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
state: false,
|
2018-05-28 23:45:29 +00:00
|
|
|
preferences: {
|
2018-12-19 17:31:51 +00:00
|
|
|
prio: 1,
|
|
|
|
trigger: ['menu:render', 'cti:reload'],
|
2018-05-28 23:45:29 +00:00
|
|
|
authentication: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
permission: ['admin.integration'],
|
2018-05-28 23:45:29 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
frontend: true
|
2018-05-28 23:45:29 +00:00
|
|
|
)
|
|
|
|
Setting.create_if_not_exists(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'cti config',
|
|
|
|
name: 'cti_config',
|
|
|
|
area: 'Integration::Cti',
|
2018-05-28 23:45:29 +00:00
|
|
|
description: 'Defines the cti config.',
|
2018-12-19 17:31:51 +00:00
|
|
|
options: {},
|
|
|
|
state: { 'outbound' => { 'routing_table' => [], 'default_caller_id' => '' }, 'inbound' => { 'block_caller_ids' => [] } },
|
2018-05-28 23:45:29 +00:00
|
|
|
preferences: {
|
2018-12-19 17:31:51 +00:00
|
|
|
prio: 2,
|
2018-05-28 23:45:29 +00:00
|
|
|
permission: ['admin.integration'],
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
frontend: false,
|
2018-05-28 23:45:29 +00:00
|
|
|
)
|
|
|
|
Setting.create_if_not_exists(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'CTI Token',
|
|
|
|
name: 'cti_token',
|
|
|
|
area: 'Integration::Cti',
|
2018-05-28 23:45:29 +00:00
|
|
|
description: 'Token for cti.',
|
2018-12-19 17:31:51 +00:00
|
|
|
options: {
|
2018-05-28 23:45:29 +00:00
|
|
|
form: [
|
|
|
|
{
|
|
|
|
display: '',
|
2018-12-19 17:31:51 +00:00
|
|
|
null: false,
|
|
|
|
name: 'cti_token',
|
|
|
|
tag: 'input',
|
2018-05-28 23:45:29 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
state: SecureRandom.urlsafe_base64(20),
|
2018-05-28 23:45:29 +00:00
|
|
|
preferences: {
|
|
|
|
permission: ['admin.integration'],
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
frontend: false
|
2018-05-28 23:45:29 +00:00
|
|
|
)
|
2018-08-09 21:06:34 +00:00
|
|
|
|
2018-08-16 06:59:28 +00:00
|
|
|
add_column :cti_logs, :queue, :string, limit: 250, null: true if !column_exists?(:cti_logs, :queue)
|
|
|
|
add_column :cti_logs, :initialized_at, :string, limit: 250, null: true if !column_exists?(:cti_logs, :initialized_at)
|
|
|
|
add_column :cti_logs, :duration_waiting_time, :integer, null: true if !column_exists?(:cti_logs, :duration_waiting_time)
|
|
|
|
add_column :cti_logs, :duration_talking_time, :integer, null: true if !column_exists?(:cti_logs, :duration_talking_time)
|
2018-08-09 21:06:34 +00:00
|
|
|
|
2018-08-14 18:03:41 +00:00
|
|
|
# fixes issue #2183 - Mysql2::Error: Invalid default value for 'start_at'
|
|
|
|
if ActiveRecord::Base.connection_config[:adapter] == 'mysql2'
|
2018-08-16 06:59:28 +00:00
|
|
|
# disable the MySQL strict_mode for the current connection
|
|
|
|
execute("SET sql_mode = ''")
|
|
|
|
|
2018-08-14 18:03:41 +00:00
|
|
|
change_column_default :cti_logs, :start, '0000-00-00 00:00:00'
|
|
|
|
change_column_default :cti_logs, :end, '0000-00-00 00:00:00'
|
|
|
|
end
|
|
|
|
|
2018-08-09 21:06:34 +00:00
|
|
|
rename_column :cti_logs, :start, :start_at
|
|
|
|
rename_column :cti_logs, :end, :end_at
|
|
|
|
|
2018-05-28 23:45:29 +00:00
|
|
|
end
|
|
|
|
end
|