From fd13a92ce01cbf13a2a6b1eed2fc01f253458870 Mon Sep 17 00:00:00 2001 From: gschechter Date: Wed, 13 Apr 2022 17:52:18 -0500 Subject: [PATCH] add comma seperated list of department ids to ignore --- config.php | 8 ++++++++ teams.php | 13 ++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/config.php b/config.php index bfc1521..f766943 100644 --- a/config.php +++ b/config.php @@ -51,6 +51,14 @@ function getOptions() { 'length' => 200 ], ]), + 'teams-csv-departmentid' => new TextboxField([ + 'label' => $__('Ignore department ids'), + 'hint' => $__('Comma delimited, ints'), + 'configuration' => [ + 'size' => 30, + 'length' => 200 + ], + ]), 'teams-message-display' => new BooleanField([ 'label' => $__('Display ticket message body in notification.'), 'hint' => $__('Uncheck to hide messages.'), diff --git a/teams.php b/teams.php index a0c69a6..69f8a1f 100644 --- a/teams.php +++ b/teams.php @@ -107,7 +107,18 @@ function sendToTeams(Ticket $ticket, $type, $colour = 'good') { error_log("$ticket_subject didn't trigger $regex_subject_ignore"); } - // Build the payload with the formatted data: + // Check the department id, see if we want to filter it + $teams_csv_departmentid = explode(',',$this->getConfig()->get('teams-csv-departmentid')); + if(in_array($ticket->getDeptId(),$teams_csv_departmentid)){ + $ost->logDebug('Ignored Message', 'Teams notification was not sent because the departmentID (' . $ticket->getDeptId() . ') matched (' . json_encode($teams_csv_departmentid) . ').'); + return; + } + else{ + error_log('DepartmentID: '.$ticket->getDeptId() ." didn't trigger ".json_encode($teams_csv_departmentid)); + } + + + // Build the payload with the formatted data: $payload = $this->createJsonMessage($ticket, $type); try {