]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
app_queue: Add option to not log Restricted Caller ID to queue_log
authorAlexei Gradinari <alex2grad@gmail.com>
Wed, 12 Jun 2024 21:18:05 +0000 (17:18 -0400)
committerAsterisk Development Team <asteriskteam@digium.com>
Thu, 11 Jul 2024 13:23:24 +0000 (13:23 +0000)
Add a queue option log-restricted-caller-id to strip the Caller ID when storing the ENTERQUEUE event
in the queue log if the Caller ID is restricted.

Resolves: #765

UpgradeNote: Add a new column to the queues table:
queue_log_option_log_restricted ENUM('0','1','off','on','false','true','no','yes')
to control whether the Restricted Caller ID will be stored in the queue log.

UserNote: Add a Queue option log-restricted-caller-id to control whether the Restricted Caller ID
will be stored in the queue log.
If log-restricted-caller-id=no then the Caller ID will be stripped if the Caller ID is restricted.

(cherry picked from commit 192a848311b0ddcedd3ce36cc00e2e26b092a0b0)

apps/app_queue.c
configs/samples/queues.conf.sample
contrib/ast-db-manage/config/versions/2b7c507d7d12_add_queue_log_option_log_restricted_.py [new file with mode: 0644]

index 7406f9dfda27c5e2c5b1265d5bfbc0d48ace4279..b4d634576167f0271e7f6b0e0240e3e74e28878e 100644 (file)
@@ -1882,6 +1882,8 @@ struct call_queue {
        int memberdelay;                    /*!< Seconds to delay connecting member to caller */
        int autofill;                       /*!< Ignore the head call status and ring an available agent */
 
+       int log_restricted_caller_id:1;     /*!< Whether log Restricted Caller ID */
+
        struct ao2_container *members;      /*!< Head of the list of members */
        struct queue_ent *head;             /*!< Head of the list of callers */
        AST_LIST_ENTRY(call_queue) list;    /*!< Next call queue */
@@ -2992,6 +2994,7 @@ static void init_queue(struct call_queue *q)
        q->autopauseunavail = 0;
        q->timeoutpriority = TIMEOUT_PRIORITY_APP;
        q->autopausedelay = 0;
+       q->log_restricted_caller_id = 1;
        if (!q->members) {
                if (q->strategy == QUEUE_STRATEGY_LINEAR || q->strategy == QUEUE_STRATEGY_RRORDERED) {
                        /* linear strategy depends on order, so we have to place all members in a list */
@@ -3517,6 +3520,8 @@ static void queue_set_param(struct call_queue *q, const char *param, const char
                } else {
                        q->timeoutpriority = TIMEOUT_PRIORITY_APP;
                }
+       } else if (!strcasecmp(param, "log-restricted-caller-id")) {
+               q->log_restricted_caller_id = ast_true(val);
        } else if (failunknown) {
                if (linenum >= 0) {
                        ast_log(LOG_WARNING, "Unknown keyword in queue '%s': %s at line %d of queues.conf\n",
@@ -8538,6 +8543,7 @@ static int queue_exec(struct ast_channel *chan, const char *data)
        struct ast_flags opts = { 0, };
        char *opt_args[OPT_ARG_ARRAY_SIZE];
        int max_forwards;
+       int cid_allow;
 
        if (ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "Queue requires an argument: queuename[,options[,URL[,announceoverride[,timeout[,agi[,gosub[,rule[,position]]]]]]]]\n");
@@ -8683,9 +8689,11 @@ static int queue_exec(struct ast_channel *chan, const char *data)
                qe.last_periodic_announce_time -= qe.parent->periodicannouncefrequency;
        }
 
+       cid_allow = qe.parent->log_restricted_caller_id || ((ast_party_id_presentation(&ast_channel_caller(chan)->id) & AST_PRES_RESTRICTION) == AST_PRES_ALLOWED);
+       
        ast_queue_log(args.queuename, ast_channel_uniqueid(chan), "NONE", "ENTERQUEUE", "%s|%s|%d",
                S_OR(args.url, ""),
-               S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, ""),
+               S_COR(cid_allow && ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, ""),
                qe.opos);
 
        /* PREDIAL: Preprocess any callee gosub arguments. */
index 88880cc4dee15b6b3f2ffcc66bb710d3da7f6607..4207a01e2d7c0f5875ceee1b751944ab979d4c7d 100644 (file)
@@ -51,6 +51,13 @@ monitor-type = MixMonitor
 ;
 ;log_membername_as_agent = no
 ;
+; log-restricted-caller-id controls whether the Restricted Caller ID will be stored
+; in the queue log.
+; If log-restricted-caller-id=no then the Caller ID will be stripped if the Caller ID
+; is restricted.
+; Default is 'yes', which means the Caller ID is always stored.
+;log-restricted-caller-id = yes
+;
 ; force_longest_waiting_caller will cause app_queue to make sure callers are offered
 ; in order (longest waiting first), even for callers across multiple queues.
 ; Before a call is offered to an agent, an additional check is made to see if the agent
diff --git a/contrib/ast-db-manage/config/versions/2b7c507d7d12_add_queue_log_option_log_restricted_.py b/contrib/ast-db-manage/config/versions/2b7c507d7d12_add_queue_log_option_log_restricted_.py
new file mode 100644 (file)
index 0000000..f85e998
--- /dev/null
@@ -0,0 +1,34 @@
+"""add queue_log option log-restricted-caller-id
+
+Revision ID: 2b7c507d7d12
+Revises: bd9c5159c7ea
+Create Date: 2024-06-12 17:00:16.841343
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '2b7c507d7d12'
+down_revision = 'bd9c5159c7ea'
+
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.dialects.postgresql import ENUM
+
+AST_BOOL_NAME = 'ast_bool_values'
+AST_BOOL_VALUES = [ '0', '1',
+                    'off', 'on',
+                    'false', 'true',
+                    'no', 'yes' ]
+
+
+def upgrade():
+    # Create the new enum
+    ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=False)
+    if op.get_context().bind.dialect.name == 'postgresql':
+        ast_bool_values.create(op.get_bind(), checkfirst=False)
+
+    op.add_column('queues', sa.Column('log_restricted_caller_id', ast_bool_values))
+
+
+def downgrade():
+    op.drop_column('queues', 'log_restricted_caller_id')