From 80d89303f5dc825317acf3369abd8ff542145a00 Mon Sep 17 00:00:00 2001 From: chahinebrini Date: Sat, 16 May 2026 03:06:34 +0200 Subject: [PATCH] fix(native/blocker): pass kind to addDomain so mail patterns route correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User added info@info.mail-slotoro.com and it landed in Eigene Domains as type=web instead of in Eigene Mails as type=mail_domain. Bug trace: 1. AddDomainSheet detects kind='mail' from the @ in the user's input 2. mailDomain() strips the local-part → "info.mail-slotoro.com" 3. handleAdd calls onAdd(pattern) — only the stripped string, no kind 4. useCustomDomains.addDomain then sends { pattern } with no kind 5. Backend Variante C auto-detect keys on @ in the pattern — but the pattern no longer contains @ (frontend already stripped it), so the detector falls into the kind='web' branch Fix: pass the kind explicitly from the sheet through the prop chain. AddDomainSheet.onAdd is now (pattern, kind?) — the sheet's handleAdd forwards the kind it detected. blocker.tsx's onAdd handler threads it into addDomain so the body includes { pattern, kind }. Backend then takes the explicit path and stores type='mail_domain' for the already-stripped value. Auto-detect on bare pattern (no kind) still works for any caller that genuinely doesn't know — that path just isn't used by the sheet anymore. --- apps/rebreak-native/app/(app)/blocker.tsx | 4 ++-- .../rebreak-native/components/blocker/AddDomainSheet.tsx | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/rebreak-native/app/(app)/blocker.tsx b/apps/rebreak-native/app/(app)/blocker.tsx index bf96943..3029392 100644 --- a/apps/rebreak-native/app/(app)/blocker.tsx +++ b/apps/rebreak-native/app/(app)/blocker.tsx @@ -409,8 +409,8 @@ export default function BlockerScreen() { setAddSheetOpen(false); refreshDomains(); }} - onAdd={async (pattern) => { - const result = await addDomain(pattern); + onAdd={async (pattern, kind) => { + const result = await addDomain(pattern, kind); if (result.ok) { const sync = await syncBlocklist(); if (sync.ok) refresh(); diff --git a/apps/rebreak-native/components/blocker/AddDomainSheet.tsx b/apps/rebreak-native/components/blocker/AddDomainSheet.tsx index 2867913..1c7bcbd 100644 --- a/apps/rebreak-native/components/blocker/AddDomainSheet.tsx +++ b/apps/rebreak-native/components/blocker/AddDomainSheet.tsx @@ -22,7 +22,7 @@ type Props = { visible: boolean; tier: Tier; onClose: () => void; - onAdd: (pattern: string) => Promise<{ ok: boolean; error?: string; alreadyGlobal?: boolean }>; + onAdd: (pattern: string, kind?: 'web' | 'mail') => Promise<{ ok: boolean; error?: string; alreadyGlobal?: boolean }>; }; function detectKind(input: string): 'web' | 'mail' | null { @@ -70,7 +70,12 @@ export function AddDomainSheet({ visible, tier, onClose, onAdd }: Props) { setAdding(true); setError(null); const pattern = kind === 'web' ? normalizeDomain(input) : normalizedMail; - const result = await onAdd(pattern); + // Pass kind explicitly — we've already stripped the local-part for mail, + // so the backend's auto-detect (which keys on the "@" character) can no + // longer infer the type from the pattern alone. Without this hint a + // "info@only4-subscribers.com" entry would land as type=web because + // the @ disappeared during the strip. + const result = await onAdd(pattern, kind === 'mail' ? 'mail' : 'web'); setAdding(false); if (result.ok) { close();