fix: rename on-time rate label, hoist getApiKey above escalation loop, remove broken capa-owner incident link
This commit is contained in:
@@ -45,6 +45,9 @@ export async function escalateOverdueCapa(
|
||||
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL ?? 'http://localhost:3000'
|
||||
let notified = 0
|
||||
|
||||
const whatsappPhoneNumberId = await getApiKey(supabase, 'META_WHATSAPP_PHONE_NUMBER_ID')
|
||||
const whatsappAccessToken = await getApiKey(supabase, 'META_WHATSAPP_ACCESS_TOKEN')
|
||||
|
||||
for (const capa of capas) {
|
||||
const threshold = getEscalationThreshold((capa as { due_date: string }).due_date)
|
||||
if (!threshold) continue
|
||||
@@ -98,14 +101,12 @@ export async function escalateOverdueCapa(
|
||||
const ownerPhone = (capa.owner as unknown as { phone: string | null } | null)?.phone ?? ''
|
||||
if (ownerPhone) {
|
||||
try {
|
||||
const phoneNumberId = await getApiKey(supabase, 'META_WHATSAPP_PHONE_NUMBER_ID')
|
||||
const accessToken = await getApiKey(supabase, 'META_WHATSAPP_ACCESS_TOKEN')
|
||||
await sendWhatsAppMessage(
|
||||
ownerPhone,
|
||||
'ims_capa_overdue',
|
||||
[incidentRef, (capa as { description: string }).description, (capa as { due_date: string }).due_date],
|
||||
phoneNumberId,
|
||||
accessToken,
|
||||
whatsappPhoneNumberId,
|
||||
whatsappAccessToken,
|
||||
)
|
||||
} catch (waErr) {
|
||||
console.error('WhatsApp escalation error:', waErr)
|
||||
|
||||
Reference in New Issue
Block a user