Skip to content

Commit

Permalink
Better check for replysatisfaction notification sending
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Sep 15, 2023
1 parent 94b4208 commit 605cd15
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/TicketSatisfaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 605cd15

Please sign in to comment.