From 5ddf6ce0cf0ee09bc6383484e94d2bef912c8e6d Mon Sep 17 00:00:00 2001 From: mstfyldz Date: Sun, 9 Aug 2026 12:09:32 +0300 Subject: [PATCH] feat: distinguish chat-only cases from real case files via kind column MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New chat threads created from the Sohbet screen were creating rows in the same cases table that Dava Dosyaları lists, so every new chat showed up there too. createCase now accepts an optional kind ('case'|'chat', default 'case') so chat-only threads can be excluded. Co-Authored-By: Claude Sonnet 5 --- src/controllers/case.controller.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/controllers/case.controller.ts b/src/controllers/case.controller.ts index 95a9900..a70df27 100644 --- a/src/controllers/case.controller.ts +++ b/src/controllers/case.controller.ts @@ -6,12 +6,16 @@ export const createCase = async (req: AuthenticatedRequest, res: Response) => { try { const userId = req.user?.id; const title = String(req.body?.title || 'Yeni Sohbet').slice(0, 200); + // kind ayrımı: 'case' = Dava Dosyaları'nda listelenen gerçek dosyalar, + // 'chat' = Sohbet ekranındaki "Yeni Sohbet" ile açılan, dosya olmayan konuşmalar. + // Dava Dosyaları listesi sadece kind='case' olanları gösteriyor. + const kind = req.body?.kind === 'chat' ? 'chat' : 'case'; // requireAuth doğrudan kullanıcının kendi id'sini set ediyor; başkasının hesabına // dosya oluşturulamaz. Yazma frontend'in anon client'ı yerine burada (service_role // ile) yapılıyor, cases için de RLS engeli yaşanmasın diye. const { data, error } = await supabase .from('cases') - .insert([{ title, user_id: userId }]) + .insert([{ title, user_id: userId, kind }]) .select('id, title') .single(); if (error) throw error;