Implement database migration, notification logs, and one-click Mailcow setup

This commit is contained in:
AyrisAI
2026-05-14 16:49:11 +03:00
parent f328296c64
commit b024e20027
18 changed files with 1067 additions and 166 deletions

View File

@@ -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 };
}

View File

@@ -1,19 +1,6 @@
/**
* lib/users.ts
* Reads user config from environment variables — no database needed.
*
* .env format:
* USER_0_NAME="Mustafa Ayris"
* USER_0_EMAIL="mustafa@ayristech.com"
* USER_0_PASSWORD="mustafa123"
* USER_0_ROLE="SUPER_ADMIN" // or "DOMAIN_ADMIN"
* USER_0_DOMAINS="*" // "*" for all, or "domain1.com,domain2.com"
*
* USER_1_NAME="Emina Karabudak"
* USER_1_EMAIL="emina@ayristech.com"
* USER_1_PASSWORD="emina123"
* USER_1_ROLE="DOMAIN_ADMIN"
* USER_1_DOMAINS="aveminakarabudak.com"
* Manages panel users via PostgreSQL database.
*/
import { prisma } from "./prisma";