admin roadmap done, reupload request, submission history, manual override

This commit is contained in:
2026-05-18 20:25:21 +07:00
parent b844ebdfac
commit bc4973a594
20 changed files with 1254 additions and 121 deletions
+25
View File
@@ -0,0 +1,25 @@
/**
* Push notif eksternal untuk admin saat ada cron FAILED atau alert critical.
* Saat ini support Discord webhook (paling simple). Fail silent — kalau env
* tidak di-set, no-op. Kalau request gagal, console.error tapi tidak throw.
*
* Env `ADMIN_ALERT_WEBHOOK_URL` — Discord channel webhook URL.
*/
export async function notifyAdmins(message: string): Promise<void> {
const webhookUrl = process.env.ADMIN_ALERT_WEBHOOK_URL;
if (!webhookUrl) return;
try {
await fetch(webhookUrl, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
// Format Discord webhook: `content` adalah body message plaintext/markdown.
content: `🚨 **SeTrip Admin Alert**\n${message}`,
}),
});
} catch (err) {
console.error("[admin-notify] gagal kirim ke webhook", err);
}
}
+6
View File
@@ -1,4 +1,5 @@
import { prisma } from "@/lib/prisma";
import { notifyAdmins } from "@/lib/admin-notify";
/**
* Wrapper untuk cron route handler — otomatis log start/finish/error ke
@@ -62,6 +63,11 @@ export async function runCron<T>(
})
.catch((e) => console.error(`[cron-runner] gagal update FAILED`, e));
}
// Fire-and-forget — jangan blok response cron route handler. Notif gagal
// di-log sendiri di `notifyAdmins`.
void notifyAdmins(
`Cron \`${jobName}\` FAILED: ${message}`
);
return { ok: false, error: message };
}
}