]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Add log-caller-id-name option to log Caller ID Name in queue log
authorphoneben <67923255+phoneben@users.noreply.github.com>
Thu, 27 Feb 2025 23:25:50 +0000 (01:25 +0200)
committergithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Wed, 16 Apr 2025 14:29:01 +0000 (14:29 +0000)
Add log-caller-id-name option to log Caller ID Name in queue log

This patch introduces a new global configuration option, log-caller-id-name,
to queues.conf to control whether the Caller ID name is logged when a call enters a queue.

When log-caller-id-name=yes, the Caller ID name is logged
as parameter 4 in the queue log, provided it’s allowed by the
existing log_restricted_caller_id rules. If log-caller-id-name=no (the default),
the Caller ID name is omitted from the logs.

Fixes: #1091
UserNote: This patch adds a global configuration option, log-caller-id-name, to queues.conf
to control whether the Caller ID name is logged as parameter 4 when a call enters a queue.
When log-caller-id-name=yes, the Caller ID name is included in the queue log,
Any '|' characters in the caller ID name will be replaced with '_'.
(provided it’s allowed by the existing log_restricted_caller_id rules).
When log-caller-id-name=no (the default), the Caller ID name is omitted.

apps/app_queue.c
configs/samples/queues.conf.sample

index d9a31c8870b84d42e264c5e12d8a3d83a7f764a5..dbef44ffaa9430b6fbfc5af03fe736ccedad4fb6 100644 (file)
@@ -1783,6 +1783,9 @@ static int log_membername_as_agent;
 /*! \brief queues.conf [general] option */
 static int force_longest_waiting_caller;
 
+/*! \brief queues.conf [general] option */
+static int log_caller_id_name; 
+
 /*! \brief name of the ringinuse field in the realtime database */
 static char *realtime_ringinuse_field;
 
@@ -8871,11 +8874,33 @@ static int queue_exec(struct ast_channel *chan, const char *data)
 
        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(cid_allow && ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, ""),
-               qe.opos);
+       if (log_caller_id_name) {
+               char *escaped_cidname = NULL;
+               /* Ensure caller ID name is valid and not NULL before processing */
+               if (cid_allow && ast_channel_caller(chan)->id.name.valid && ast_channel_caller(chan)->id.name.str) {
+                       escaped_cidname = ast_strdupa(ast_channel_caller(chan)->id.name.str);
+                       /* Only iterate if '|' is found */
+                       if (strchr(escaped_cidname, '|')) {
+                               for (char *p = escaped_cidname; *p; p++) {
+                                       if (*p == '|') {
+                                               *p = '_';
+                                       }
+                               }
+                       }
+               }
 
+               ast_queue_log(args.queuename, ast_channel_uniqueid(chan), "NONE", "ENTERQUEUE", "%s|%s|%d|%s",
+                       S_OR(args.url, ""),
+                       S_COR(cid_allow && ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, ""),
+                       qe.opos,
+                       S_OR(escaped_cidname, ""));
+       } else {
+               ast_queue_log(args.queuename, ast_channel_uniqueid(chan), "NONE", "ENTERQUEUE", "%s|%s|%d",
+                       S_OR(args.url, ""),
+                       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. */
        if (ast_test_flag(&opts, OPT_PREDIAL_CALLEE)
                && !ast_strlen_zero(opt_args[OPT_ARG_PREDIAL_CALLEE])) {
@@ -9784,6 +9809,10 @@ static void queue_set_global_params(struct ast_config *cfg)
        if ((general_val = ast_variable_retrieve(cfg, "general", "force_longest_waiting_caller"))) {
                force_longest_waiting_caller = ast_true(general_val);
        }
+       /* Apply log-caller-id-name in the same place as other global settings */
+       if ((general_val = ast_variable_retrieve(cfg, "general", "log-caller-id-name"))) {
+               log_caller_id_name = ast_true(general_val);
+       }
 }
 
 /*! \brief reload information pertaining to a single member
index 1b853eee6cef91e356791bb3d15bf13ef391b3f1..901472e48e868801518c077f47b88b5cd9f25bd8 100644 (file)
@@ -51,6 +51,15 @@ monitor-type = MixMonitor
 ;
 ;log_membername_as_agent = no
 ;
+; log-caller-id-name controls whether the Caller ID Name will be written to the
+; queue log. If enabled, and Caller ID would otherwise be logged (see
+; 'log-restricted-caller-id'), adds a 4th column to the ENTERQUEUE record which
+; contains the Caller ID Name. Any '|' characters in the Caller ID Name will be
+; replaced by a '_'. This setting applies globally to all queues.
+;
+; Default is 'no', which means the Caller ID Name is not stored.
+;log-caller-id-name = 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