fix(native/blocker): pass kind to addDomain so mail patterns route correctly
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.
This commit is contained in:
parent
26de3dade9
commit
80d89303f5
@ -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();
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user