Skip to content

Commit

Permalink
privacy processing (#1423)
Browse files Browse the repository at this point in the history
* privacy processing
  • Loading branch information
dmitry-sinina authored Feb 15, 2024
1 parent 4ce5af5 commit 64da729
Show file tree
Hide file tree
Showing 10 changed files with 5,414 additions and 136 deletions.
20 changes: 4 additions & 16 deletions app/admin/cdr/cdrs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,8 @@ def scoped_collection
head 200
end

member_action :download_call_record_lega, method: :get do
file = resource.call_record_filename_lega
raise ActiveRecord::RecordNotFound if file.blank?

response.headers['X-Accel-Redirect'] = file
head 200
end

member_action :download_call_record_legb, method: :get do
file = resource.call_record_filename_legb
member_action :download_call_record, method: :get do
file = resource.call_record_filename
raise ActiveRecord::RecordNotFound if file.blank?

response.headers['X-Accel-Redirect'] = file
Expand Down Expand Up @@ -233,12 +225,8 @@ def scoped_collection
link_to("#{resource.dump_level_name} trace", dump_cdr_path(resource)) if resource.has_dump?
end

action_item :call_record_lega, only: :show do
link_to('Call record LegA', download_call_record_lega_cdr_path(resource)) if resource.audio_recorded?
end

action_item :call_record_lega, only: :show do
link_to('Call record LegB', download_call_record_legb_cdr_path(resource)) if resource.audio_recorded?
action_item :call_record, only: :show do
link_to('Call record', download_call_record_cdr_path(resource)) if resource.audio_recorded?
end

action_item :download_csv, only: :index do
Expand Down
4 changes: 4 additions & 0 deletions app/admin/equipment/gateways.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
:suppress_early_media,
:send_lnp_information,
:force_one_way_early_media, :max_30x_redirects,
:privacy_mode_name,
:stir_shaken_mode_name,
[:stir_shaken_crt_name, proc { |row| row.stir_shaken_crt.try(:name) }]

Expand Down Expand Up @@ -315,6 +316,7 @@ def resource_params
filter :codec_group, input_html: { class: 'chosen' }, collection: proc { CodecGroup.pluck(:name, :id) }
filter :diversion_send_mode
filter :sip_schema_id, as: :select, collection: proc { Gateway::SIP_SCHEMAS.invert }
filter :privacy_mode_id, as: :select, collection: proc { Gateway::PRIVACY_MODES.invert }

form do |f|
f.semantic_errors *f.object.errors.attribute_names
Expand Down Expand Up @@ -440,6 +442,7 @@ def resource_params
end
tab 'Translations' do
f.inputs 'Translations' do
f.input :privacy_mode_id, as: :select, include_blank: false, collection: Gateway::PRIVACY_MODES.invert
f.input :termination_src_numberlist, input_html: { class: 'chosen' }, include_blank: 'None'
f.input :termination_dst_numberlist, input_html: { class: 'chosen' }, include_blank: 'None'
f.input :diversion_send_mode, include_blank: false
Expand Down Expand Up @@ -628,6 +631,7 @@ def resource_params
end
tab 'Translations' do
attributes_table_for s do
row :privacy_mode_id, &:privacy_mode_name
row :termination_src_numberlist
row :termination_dst_numberlist
row :diversion_send_mode
Expand Down
8 changes: 2 additions & 6 deletions app/models/cdr/cdr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,8 @@ def dump_filename
end
end

def call_record_filename_lega
"/record/#{local_tag}_legA.mp3" if local_tag.present? && node_id.present?
end

def call_record_filename_legb
"/record/#{local_tag}_legB.mp3" if local_tag.present? && node_id.present?
def call_record_filename
"/record/#{local_tag}.mp3" if local_tag.present? && node_id.present?
end

def attempts
Expand Down
16 changes: 16 additions & 0 deletions app/models/customers_auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ class CustomersAuth < ApplicationRecord
SS_STATUS_C => 'Attestation C'
}.freeze

PRIVACY_MODE_ALLOW = 1
PRIVACY_MODE_REJECT = 2
PRIVACY_MODE_REJECT_CRITICAL = 3
PRIVACY_MODE_REJECT_ANONYMOUS = 4
PRIVACY_MODES = {
PRIVACY_MODE_ALLOW => 'Allow any calls',
PRIVACY_MODE_REJECT => 'Reject private calls',
PRIVACY_MODE_REJECT_CRITICAL => 'Reject critical private calls',
PRIVACY_MODE_REJECT_ANONYMOUS => 'Reject anonymous(no CLI/PAI/PPI)'
}.freeze

module CONST
MATCH_CONDITION_ATTRIBUTES = %i[ip
src_prefix
Expand Down Expand Up @@ -212,6 +223,7 @@ module CONST
validates :dump_level_id, presence: true
validates :dump_level_id, inclusion: { in: CustomersAuth::DUMP_LEVELS.keys }, allow_nil: true
validates :rewrite_ss_status_id, inclusion: { in: CustomersAuth::SS_STATUSES.keys }, allow_nil: true
validates :privacy_mode_id, inclusion: { in: PRIVACY_MODES.keys }, allow_nil: false

validates_with TagActionValueValidator

Expand Down Expand Up @@ -262,6 +274,10 @@ def rewrite_ss_status_name
rewrite_ss_status_id.nil? ? nil : SS_STATUSES[rewrite_ss_status_id]
end

def privacy_mode_name
PRIVACY_MODES[privacy_mode_id]
end

# TODO: move to decorator when ActiveAdmin fix problem
# Problem is:
# on "update" AA uses decorated object
Expand Down
24 changes: 23 additions & 1 deletion app/models/gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,13 @@ class Gateway < ApplicationRecord
PAI_SEND_MODE_BUILD_TEL = 1
PAI_SEND_MODE_BUILD_SIP = 2
PAI_SEND_MODE_BUILD_SIP_WITH_USER_PHONE = 3
PAI_SEND_MODE_RELAY = 4
PAI_SEND_MODES = {
PAI_SEND_MODE_NO_SEND => 'Do not send',
PAI_SEND_MODE_BUILD_TEL => 'Build TEL URI from Source Number',
PAI_SEND_MODE_BUILD_SIP => 'Build SIP URI from Source Number',
PAI_SEND_MODE_BUILD_SIP_WITH_USER_PHONE => 'Build SIP URI from Source Number with user=phone'
PAI_SEND_MODE_BUILD_SIP_WITH_USER_PHONE => 'Build SIP URI from Source Number with user=phone',
PAI_SEND_MODE_RELAY => 'Relay PAI and PPI'
}.freeze

REGISTERED_AOR_MODE_NO_USE = 0
Expand Down Expand Up @@ -209,6 +211,21 @@ class Gateway < ApplicationRecord
SIP_SCHEMA_SIP_WITH_USER_PHONE => 'sip with user=phone'
}.freeze

PRIVACY_MODE_DISABLE = 0
PRIVACY_MODE_SKIP = 1
PRIVACY_MODE_SKIP_CRITICAL = 2
PRIVACY_MODE_APPLY = 3
PRIVACY_MODE_TRUSTED = 4
PRIVACY_MODE_TRUSTED_REMOVE_FROM = 5
PRIVACY_MODES = {
PRIVACY_MODE_DISABLE => 'Do nothing',
PRIVACY_MODE_SKIP => 'Skip for private calls',
PRIVACY_MODE_SKIP_CRITICAL => 'Skip for critical private calls',
PRIVACY_MODE_APPLY => 'Not trusted gw. Apply',
PRIVACY_MODE_TRUSTED => 'Trusted gw. Forward',
PRIVACY_MODE_TRUSTED_REMOVE_FROM => 'Trusted gw. Forward. Anonymize from'
}.freeze

class << self
# Returns a reference if host is IPv6, otherwise returns host
# @param value [String]
Expand Down Expand Up @@ -305,6 +322,7 @@ def normalize_host(value)
validates :stir_shaken_mode_id, inclusion: { in: STIR_SHAKEN_MODES.keys }, allow_nil: false
validates :stir_shaken_crt_id, presence: true, if: -> { stir_shaken_mode_id == STIR_SHAKEN_MODE_INSERT }
validates :sip_schema_id, inclusion: { in: SIP_SCHEMAS.keys }, allow_nil: false
validates :privacy_mode_id, inclusion: { in: PRIVACY_MODES.keys }, allow_nil: false

validate :vendor_owners_the_gateway_group
validate :vendor_can_be_changed
Expand Down Expand Up @@ -413,6 +431,10 @@ def sip_schema_name
SIP_SCHEMAS[sip_schema_id]
end

def privacy_mode_name
PRIVACY_MODES[privacy_mode_id]
end

def use_registered_aor?
registered_aor_mode_id > 0
end
Expand Down
Loading

0 comments on commit 64da729

Please sign in to comment.