From 605cd15bb9871d64793dfa875d6b5abc164d49c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Tue, 12 Sep 2023 14:51:03 +0200 Subject: [PATCH] Better check for `replysatisfaction` notification sending --- src/TicketSatisfaction.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/TicketSatisfaction.php b/src/TicketSatisfaction.php index c385fd960f6..23bdaa99bad 100644 --- a/src/TicketSatisfaction.php +++ b/src/TicketSatisfaction.php @@ -200,9 +200,14 @@ public function post_UpdateItem($history = 1) global $CFG_GLPI; if (!isset($this->input['_disablenotif']) && $CFG_GLPI["use_notifications"]) { + // Send notification only if fields related to reply are updated. + $answer_updates = array_filter( + $this->updates, + fn ($field) => in_array($field, ['satisfaction', 'comment']) + ); + $ticket = new Ticket(); - // date_answer is always updated even if the comment or rate does not change - if (count($this->updates) > 1 && $ticket->getFromDB($this->fields['tickets_id'])) { + if (count($answer_updates) > 1 && $ticket->getFromDB($this->fields['tickets_id'])) { NotificationEvent::raiseEvent("replysatisfaction", $ticket); } }