diff --git a/apps/app_queue.c b/apps/app_queue.c index 75101ec4df..02417f3342 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -1900,6 +1900,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 */ @@ -3012,6 +3014,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 */ @@ -3543,6 +3546,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", @@ -8628,6 +8633,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[,macro[,gosub[,rule[,position]]]]]]]]]\n"); @@ -8774,9 +8780,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. */ diff --git a/configs/samples/queues.conf.sample b/configs/samples/queues.conf.sample index 003e3636a0..e20a6d97a4 100644 --- a/configs/samples/queues.conf.sample +++ b/configs/samples/queues.conf.sample @@ -58,6 +58,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 index 0000000000..f85e998932 --- /dev/null +++ b/contrib/ast-db-manage/config/versions/2b7c507d7d12_add_queue_log_option_log_restricted_.py @@ -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')