fix: use JSON for mail mappings to fix deployment shell error
This commit is contained in:
@@ -19,9 +19,17 @@ export async function POST(req: NextRequest) {
|
||||
|
||||
console.log(`[Mail Webhook] Yeni mail geldi: ${sender} -> ${aliciMail}`);
|
||||
|
||||
// 1. Find which USER_X owns this mail address via MAIL_email=USER_X mapping
|
||||
const envKey = `MAIL_${aliciMail}`;
|
||||
const ownerUserKey = process.env[envKey]; // e.g., "USER_0"
|
||||
// 1. Find which USER_X owns this mail address via JSON mapping
|
||||
// Format: MAIL_USER_MAPPINGS='{"email1@domain.com":"USER_0", "email2@domain.com":"USER_1"}'
|
||||
const mappingsRaw = process.env.MAIL_USER_MAPPINGS || "{}";
|
||||
let ownerUserKey: string | undefined = undefined;
|
||||
|
||||
try {
|
||||
const mappings = JSON.parse(mappingsRaw);
|
||||
ownerUserKey = mappings[aliciMail];
|
||||
} catch (e) {
|
||||
console.error("[Mail Webhook] MAIL_USER_MAPPINGS JSON ayrıştırma hatası:", e);
|
||||
}
|
||||
|
||||
if (ownerUserKey) {
|
||||
// 2. Get that USER's Telegram ID (e.g., USER_0_TELEGRAM_ID)
|
||||
|
||||
Reference in New Issue
Block a user