Skip to content

Commit

Permalink
Add pending notifications incident history messages
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab committed Oct 25, 2023
1 parent 857429d commit 8fe79c4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 13 deletions.
6 changes: 4 additions & 2 deletions library/Notifications/Model/IncidentHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public function getColumns()
'old_severity',
'new_recipient_role',
'old_recipient_role',
'message'
'message',
'notification_state',
'sent_at'
];
}

Expand All @@ -66,7 +68,7 @@ public function getColumnDefinitions()

public function createBehaviors(Behaviors $behaviors)
{
$behaviors->add(new MillisecondTimestamp(['time']));
$behaviors->add(new MillisecondTimestamp(['time', 'sent_at']));
}

public function getDefaultSort()
Expand Down
49 changes: 38 additions & 11 deletions library/Notifications/Widget/ItemList/IncidentHistoryListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,24 +169,51 @@ protected function buildMessage(): string
break;
case "notified":
if ($this->item->contactgroup_id) {
$message = sprintf(
t('Contact %s notified via %s as member of contact group %s'),
$this->item->contact->full_name,
$this->item->channel->type,
$this->item->contactgroup->name
);
if ($this->item->notification_state === 'sent') {
$message = sprintf(
t('Contact %s notified via %s as member of contact group %s'),
$this->item->contact->full_name,
$this->item->channel->type,
$this->item->contactgroup->name
);
} else {
$message = sprintf(
t('Contact %s notified via %s as member of contact group %s (%s)'),
$this->item->contact->full_name,
$this->item->channel->type,
$this->item->contactgroup->name,
$this->item->notification_state
);
}
} elseif ($this->item->schedule_id) {
if ($this->item->notfication_state === 'sent') {
$message = sprintf(
t('Contact %s notified via %s as member of schedule %s'),
$this->item->contact->full_name,
$this->item->channel->type,
$this->item->schedule->name
);
} else {
$message = sprintf(
t('Contact %s notified via %s as member of schedule %s (%s)'),
$this->item->contact->full_name,
$this->item->schedule->name,
$this->item->channel->type,
$this->item->notification_state
);
}
} elseif ($this->item->notification_state === 'sent') {
$message = sprintf(
t('Contact %s notified via %s as member of schedule %s'),
t('Contact %s notified via %s'),
$this->item->contact->full_name,
$this->item->channel->type,
$this->item->schedule->name
$this->item->channel->type
);
} else {
$message = sprintf(
t('Contact %s notified via %s'),
t('Contact %s notified via %s (%s)'),
$this->item->contact->full_name,
$this->item->channel->type
$this->item->channel->type,
$this->item->notification_state
);
}
break;
Expand Down

0 comments on commit 8fe79c4

Please sign in to comment.