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}`);
|
console.log(`[Mail Webhook] Yeni mail geldi: ${sender} -> ${aliciMail}`);
|
||||||
|
|
||||||
// 1. Find which USER_X owns this mail address via MAIL_email=USER_X mapping
|
// 1. Find which USER_X owns this mail address via JSON mapping
|
||||||
const envKey = `MAIL_${aliciMail}`;
|
// Format: MAIL_USER_MAPPINGS='{"email1@domain.com":"USER_0", "email2@domain.com":"USER_1"}'
|
||||||
const ownerUserKey = process.env[envKey]; // e.g., "USER_0"
|
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) {
|
if (ownerUserKey) {
|
||||||
// 2. Get that USER's Telegram ID (e.g., USER_0_TELEGRAM_ID)
|
// 2. Get that USER's Telegram ID (e.g., USER_0_TELEGRAM_ID)
|
||||||
|
|||||||
Reference in New Issue
Block a user