Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-sinina committed Dec 15, 2024
1 parent 899d312 commit 160c797
Show file tree
Hide file tree
Showing 15 changed files with 1,532 additions and 223 deletions.
39 changes: 26 additions & 13 deletions app/admin/routing/customers_auths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
:send_billing_information,
:diversion_policy_name,
:diversion_rewrite_rule, :diversion_rewrite_result,
:pai_policy_name,
:pai_policy_name, :pai_rewrite_rule, :pai_rewrite_result,
[:src_number_field_name, proc { |row| row.src_number_field.try(:name) }],
[:src_name_field_name, proc { |row| row.src_name_field.try(:name) }],
[:dst_number_field_name, proc { |row| row.dst_number_field.try(:name) }],
Expand Down Expand Up @@ -74,7 +74,7 @@
permit_params :name, :enabled, :reject_calls, :customer_id, :rateplan_id, :routing_plan_id,
:gateway_id, :require_incoming_auth, :account_id, :check_account_balance,
:diversion_policy_id, :diversion_rewrite_rule, :diversion_rewrite_result,
:pai_policy_id,
:pai_policy_id, :pai_rewrite_rule, :pai_rewrite_result,
:src_name_rewrite_rule, :src_name_rewrite_result,
:src_rewrite_rule, :src_rewrite_result, :dst_rewrite_rule,
:dst_rewrite_result,
Expand Down Expand Up @@ -317,11 +317,6 @@ def update
scope: Routing::Numberlist.order(:name),
path: '/numberlists/search'
f.input :dump_level_id, as: :select, include_blank: false, collection: CustomersAuth::DUMP_LEVELS.invert
f.input :privacy_mode_id,
as: :select,
include_blank: false,
collection: CustomersAuth::PRIVACY_MODES.invert,
input_html: { class: :chosen }
f.input :enable_audio_recording
f.input :capacity
f.input :cps_limit
Expand Down Expand Up @@ -349,22 +344,38 @@ def update

tab :number_translation do
f.inputs do
f.input :diversion_policy_id, as: :select, include_blank: false, collection: CustomersAuth::DIVERSION_POLICIES.invert
f.input :privacy_mode_id,
as: :select,
include_blank: false,
collection: CustomersAuth::PRIVACY_MODES.invert,
input_html: { class: :chosen }

f.input :diversion_policy_id,
as: :select,
include_blank: false,
collection: CustomersAuth::DIVERSION_POLICIES.invert,
input_html: { class: :chosen }
f.input :diversion_rewrite_rule
f.input :diversion_rewrite_result
f.input :src_numberlist_use_diversion

f.input :pai_policy_id, as: :select, include_blank: false, collection: CustomersAuth::PAI_POLICIES.invert
f.input :pai_policy_id,
as: :select,
include_blank: false,
collection: CustomersAuth::PAI_POLICIES.invert,
input_html: { class: :chosen }
f.input :pai_rewrite_rule
f.input :pai_rewrite_result

f.input :src_name_field, as: :select, include_blank: false
f.input :src_name_field, as: :select, include_blank: false, input_html: { class: :chosen }
f.input :src_name_rewrite_rule
f.input :src_name_rewrite_result

f.input :src_number_field, as: :select, include_blank: false
f.input :src_number_field, as: :select, include_blank: false, input_html: { class: :chosen }
f.input :src_rewrite_rule
f.input :src_rewrite_result

f.input :dst_number_field, as: :select, include_blank: false
f.input :dst_number_field, as: :select, include_blank: false, input_html: { class: :chosen }
f.input :dst_rewrite_rule
f.input :dst_rewrite_result
f.input :lua_script, input_html: { class: 'chosen' }, include_blank: 'None'
Expand Down Expand Up @@ -438,7 +449,6 @@ def update
row :src_numberlist

row :dump_level, &:dump_level_name
row :privacy_mode_id, &:privacy_mode_name
row :enable_audio_recording
row :capacity
row :cps_limit
Expand Down Expand Up @@ -466,12 +476,15 @@ def update
end
tab :number_translation do
attributes_table do
row :privacy_mode_id, &:privacy_mode_name
row :diversion_policy, &:diversion_policy_name
row :diversion_rewrite_rule
row :diversion_rewrite_result
row :src_numberlist_use_diversion

row :pai_policy, &:pai_policy_name
row :pai_rewrite_rule
row :pai_rewrite_result

row :src_name_field
row :src_name_rewrite_rule
Expand Down
4 changes: 4 additions & 0 deletions app/models/customers_auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
# interface :string default([]), not null, is an Array
# ip :inet default(["\"127.0.0.0/8\""]), is an Array
# name :string not null
# pai_rewrite_result :string
# pai_rewrite_rule :string
# reject_calls :boolean default(FALSE), not null
# require_incoming_auth :boolean default(FALSE), not null
# send_billing_information :boolean default(FALSE), not null
Expand Down Expand Up @@ -338,9 +340,11 @@ def ss_invalid_identity_action_name
def ss_no_identity_action_name
ss_no_identity_action_id.nil? ? nil : SS_NO_IDENTITY_ACTIONS[ss_no_identity_action_id]
end

def pai_policy_name
PAI_POLICIES[pai_policy_id]
end

def diversion_policy_name
DIVERSION_POLICIES[diversion_policy_id]
end
Expand Down
2 changes: 2 additions & 0 deletions app/models/customers_auth_normalized.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
# interface :string
# ip :inet not null
# name :string not null
# pai_rewrite_result :string
# pai_rewrite_rule :string
# reject_calls :boolean default(FALSE), not null
# require_incoming_auth :boolean default(FALSE), not null
# send_billing_information :boolean default(FALSE), not null
Expand Down
1 change: 1 addition & 0 deletions app/models/disconnect_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def display_name
DC_NO_DESTINATION_WITH_APPROPRIATE_RATE = 8006
DC_IDENTITY_REQUIRED = 8018
DC_IDENTITY_INVALID = 8019
DC_PAI_REQUIRED = 8020

def namespace_name
NSS[namespace_id]
Expand Down
13 changes: 8 additions & 5 deletions app/models/gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ class Gateway < ApplicationRecord
PAI_SEND_MODE_BUILD_SIP = 2
PAI_SEND_MODE_BUILD_SIP_WITH_USER_PHONE = 3
PAI_SEND_MODE_RELAY = 4
PAI_SEND_MODE_RELAY_AS_TEL = 5,
PAI_SEND_MODE_RELAY_AS_TEL = 5
PAI_SEND_MODE_RELAY_AS_SIP = 6
PAI_SEND_MODE_RELAY_AS_SIP_FORCE_DOMAIN = 7
PAI_SEND_MODES = {
PAI_SEND_MODE_NO_SEND => 'Do not send',
PAI_SEND_MODE_BUILD_TEL => 'Build TEL URI from Source Number',
Expand All @@ -190,15 +191,16 @@ class Gateway < ApplicationRecord
PAI_SEND_MODE_RELAY => 'Relay PAI/PPI as is',
PAI_SEND_MODE_RELAY_AS_TEL => 'Relay PAI/PPI as TEL uri',
PAI_SEND_MODE_RELAY_AS_SIP => 'Relay PAI/PPI as SIP uri',
PAI_SEND_MODE_RELAY_AS_SIP_FORCE_DOMAIN => 'Relay PAI/PPI as SIP uri. Replace domain'
}.freeze

REGISTERED_AOR_MODE_NO_USE = 0
REGISTERED_AOR_MODE_AS_IS = 1
REGISTERED_AOR_MODE_REPLACE_USERPART = 2
REGISTERED_AOR_MODES = {
PAI_SEND_MODE_NO_SEND => 'Do not use',
PAI_SEND_MODE_BUILD_TEL => 'Use AOR as is',
PAI_SEND_MODE_BUILD_SIP => 'Use AOR, replace userpart with dst number'
REGISTERED_AOR_MODE_NO_USE => 'Do not use',
REGISTERED_AOR_MODE_AS_IS => 'Use AOR as is',
REGISTERED_AOR_MODE_REPLACE_USERPART => 'Use AOR, replace userpart with dst number'
}.freeze

STIR_SHAKEN_MODE_DISABLE = 0
Expand Down Expand Up @@ -322,7 +324,8 @@ def normalize_host(value)
presence: true,
if: proc {
pai_send_mode_id in [
PAI_SEND_MODE_BUILD_SIP, PAI_SEND_MODE_BUILD_SIP_WITH_USER_PHONE, PAI_SEND_MODE_RELAY_AS_SIP
PAI_SEND_MODE_BUILD_SIP, PAI_SEND_MODE_BUILD_SIP_WITH_USER_PHONE,
PAI_SEND_MODE_RELAY_AS_SIP, PAI_SEND_MODE_RELAY_AS_SIP_FORCE_DOMAIN
]
}

Expand Down
8 changes: 7 additions & 1 deletion app/models/importing/customers_auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
# max_dst_number_length :integer(2)
# min_dst_number_length :integer(2)
# name :string
# pai_policy_name :string
# pai_rewrite_result :string
# pai_rewrite_rule :string
# pop_name :string
# privacy_mode_name :string
# radius_accounting_profile_name :string
Expand Down Expand Up @@ -66,13 +69,14 @@
# x_yeti_auth :string
# account_id :integer(4)
# customer_id :integer(4)
# diversion_policy_id :integer(4)
# diversion_policy_id :integer(2)
# dst_number_field_id :integer(2)
# dst_numberlist_id :integer(4)
# dump_level_id :integer(4)
# gateway_id :integer(4)
# lua_script_id :integer(2)
# o_id :bigint(8)
# pai_policy_id :integer(2)
# pop_id :integer(4)
# privacy_mode_id :integer(2)
# radius_accounting_profile_id :integer(2)
Expand Down Expand Up @@ -160,9 +164,11 @@ class Importing::CustomersAuth < Importing::Base
def dump_level_display_name
dump_level_id.nil? ? 'unknown' : CustomersAuth::DUMP_LEVELS[dump_level_id]
end

def diversion_policy_display_name
diversion_policy_id.nil? ? 'unknown' : CustomersAuth::DIVERSION_POLICIES[diversion_policy_id]
end

def pai_policy_display_name
pai_policy_id.nil? ? 'unknown' : CustomersAuth::PAI_POLICIES[pai_policy_id]
end
Expand Down
35 changes: 0 additions & 35 deletions db/migrate/20241213172819_switch22_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,41 +301,6 @@ def up
);
CREATE FUNCTION switch22.build_uri(i_canonical boolean, i_schema character varying, i_display_name character varying, i_username character varying, i_username_params character varying[], i_domain character varying, i_port integer, i_uri_params character varying[]) RETURNS character varying
LANGUAGE plpgsql STABLE SECURITY DEFINER COST 10
AS $$
DECLARE
v_domainport varchar;
v_username varchar;
v_uri varchar;
BEGIN
if coalesce(cardinality(i_username_params),0) >0 then
v_username = i_username||';'||array_to_string(i_username_params,';');
else
v_username = i_username;
end if;
-- adding username, domain and port. Username and port are optional
v_uri = COALESCE(v_username||'@','')||i_domain||COALESCE(':'||i_port::varchar,'');
-- adding params after domainport if exists
if coalesce(cardinality(i_uri_params),0)>0 then
v_uri = v_uri||';'||array_to_string(i_uri_params,';');
end if;
if i_canonical then
v_uri = i_schema||':'||v_uri;
else
v_uri = COALESCE(i_display_name||' ','')||'<'||i_schema||':'||v_uri||'>';
end if;
return v_uri;
END;
$$;
CREATE FUNCTION switch22.check_event(i_event_id integer) RETURNS boolean
LANGUAGE plpgsql COST 10
AS $$
Expand Down
Loading

0 comments on commit 160c797

Please sign in to comment.