[Web] More mailq fixes

master
andryyy 2018-10-25 23:03:35 +02:00
parent a6b615f268
commit 70a914a98c
1 changed files with 12 additions and 9 deletions

View File

@ -37,7 +37,6 @@ function mailq($_action, $_data = null) {
switch ($_action) {
case 'get':
$mailq_lines = docker('post', 'postfix-mailcow', 'exec', array('cmd' => 'mailq', 'task' => 'list'));
$mailq_lines .= '{"queue_name":"hold","queue_id":"6004D1021DE","arrival_time":1540195064,"message_size":269,"sender":"watchdog@invalid","recipients":[{"address":"test@example.com","delay_reason":"connect to 123.0.0.1[123.0.0.1]:25: Connection refused"},{"address":"test@example.com","delay_reason":"connect to 123.0.0.1[123.0.0.1]:25: Connection refused"}]}';
$lines = 0;
// Hard limit to 10000 items
foreach (preg_split("/((\r?\n)|(\r\n?))/", $mailq_lines) as $mailq_item) if ($lines++ < 10000) {
@ -45,17 +44,21 @@ function mailq($_action, $_data = null) {
continue;
}
$mq_line = json_decode($mailq_item, true);
$rcpts = array();
foreach ($mq_line['recipients'] as $rcpt) {
if (isset($rcpt['delay_reason'])) {
$rcpts[] = $rcpt['address'] . ' (' . $rcpt['delay_reason'] . ')';
if ($mq_line !== NULL) {
$rcpts = array();
foreach ($mq_line['recipients'] as $rcpt) {
if (isset($rcpt['delay_reason'])) {
$rcpts[] = $rcpt['address'] . ' (' . $rcpt['delay_reason'] . ')';
}
else {
$rcpts[] = $rcpt['address'];
}
}
else {
$rcpts[] = $rcpt['address'];
if (!empty($rcpts)) {
$mq_line['recipients'] = $rcpts;
}
$line[] = $mq_line;
}
$mq_line['recipients'] = $rcpts;
$line[] = $mq_line;
}
if (!isset($line) || empty($line)) {
return '{}';