Implement database migration, notification logs, and one-click Mailcow setup
This commit is contained in:
@@ -28,7 +28,8 @@ async function mfetch(path: string, options: RequestInit = {}) {
|
||||
cache: "no-store",
|
||||
});
|
||||
if (!res.ok) {
|
||||
const text = await res.text();
|
||||
const clone = res.clone();
|
||||
const text = await clone.text();
|
||||
console.error(`[Mailcow API] Error ${res.status}: ${text}`);
|
||||
}
|
||||
return res;
|
||||
@@ -228,3 +229,23 @@ export async function getDKIM(domain: string) {
|
||||
if (!res.ok) return null;
|
||||
return res.json();
|
||||
}
|
||||
|
||||
// ─── Forwarding / Webhook Setup ──────────────────────────────
|
||||
// Automates the "one-click" configuration of mailbox notifications
|
||||
export async function setupMailboxForwarding(address: string, webhookUrl: string) {
|
||||
// Check if webhookUrl is localhost and warn in console
|
||||
if (webhookUrl.includes("localhost")) {
|
||||
console.warn(`[Setup] WARNING: Using localhost for webhook (${webhookUrl}). Mailcow will not be able to reach this!`);
|
||||
}
|
||||
|
||||
const body = {
|
||||
address: address,
|
||||
goto: webhookUrl,
|
||||
active: 1,
|
||||
sogo_visible: 0,
|
||||
};
|
||||
const res = await mfetch("/add/alias", { method: "POST", body: JSON.stringify(body) });
|
||||
const data = await res.json();
|
||||
return { ok: res.ok, data };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user