55 lines
1.9 KiB
PowerShell
55 lines
1.9 KiB
PowerShell
|
|
# scripts/check-mail.ps1
|
||
|
|
# One command to prove the letter pipeline works BEFORE you rely on it.
|
||
|
|
#
|
||
|
|
# powershell -ExecutionPolicy Bypass -File scripts\check-mail.ps1
|
||
|
|
#
|
||
|
|
# Exits 0 when a resignation letter would actually be delivered.
|
||
|
|
# Exits 1 when something would silently drop it, and prints the fix.
|
||
|
|
#
|
||
|
|
# Why this exists: on 2026-10-09 a resignation letter for SUNE PIETERS was
|
||
|
|
# reported as "sent successfully" while himalaya was missing from PATH and
|
||
|
|
# the PDF service was down. Nothing failed loudly. This script makes it loud.
|
||
|
|
|
||
|
|
param(
|
||
|
|
[string]$BaseUrl = 'http://localhost:6001'
|
||
|
|
)
|
||
|
|
|
||
|
|
$ErrorActionPreference = 'Stop'
|
||
|
|
|
||
|
|
try {
|
||
|
|
$res = Invoke-WebRequest -Uri "$BaseUrl/api/mail-health" -UseBasicParsing -TimeoutSec 120
|
||
|
|
$body = $res.Content | ConvertFrom-Json
|
||
|
|
} catch {
|
||
|
|
Write-Host ''
|
||
|
|
Write-Host ' [FAIL] Could not reach the app health endpoint.' -ForegroundColor Red
|
||
|
|
Write-Host " $($_.Exception.Message)"
|
||
|
|
Write-Host ''
|
||
|
|
Write-Host ' Is the dev server running on port 6001?' -ForegroundColor Yellow
|
||
|
|
Write-Host ' Then run: powershell -ExecutionPolicy Bypass -File scripts\check-mail.ps1' -ForegroundColor Yellow
|
||
|
|
Write-Host ''
|
||
|
|
exit 1
|
||
|
|
}
|
||
|
|
|
||
|
|
$icon = @{ ok = ' [ OK ]'; warn = ' [WARN]'; fail = ' [FAIL]' }
|
||
|
|
$colour = @{ ok = 'Green'; warn = 'Yellow'; fail = 'Red' }
|
||
|
|
|
||
|
|
Write-Host ''
|
||
|
|
Write-Host ' Workflow mail health check' -ForegroundColor Cyan
|
||
|
|
Write-Host ' --------------------------' -ForegroundColor DarkGray
|
||
|
|
Write-Host ''
|
||
|
|
|
||
|
|
foreach ($c in $body.checks) {
|
||
|
|
Write-Host ("{0} {1,-18} {2}" -f $icon[$c.status], $c.name, $c.detail) -ForegroundColor $colour[$c.status]
|
||
|
|
if ($c.fix) { Write-Host (" -> {0}" -f $c.fix) -ForegroundColor DarkYellow }
|
||
|
|
}
|
||
|
|
|
||
|
|
Write-Host ''
|
||
|
|
if ($body.ok) {
|
||
|
|
Write-Host ' RESULT: letters will send.' -ForegroundColor Green
|
||
|
|
Write-Host ''
|
||
|
|
exit 0
|
||
|
|
} else {
|
||
|
|
Write-Host ' RESULT: letters would be LOST. Fix the [FAIL] items above.' -ForegroundColor Red
|
||
|
|
Write-Host ''
|
||
|
|
exit 1
|
||
|
|
}
|