feat: distinguish chat-only cases from real case files via kind column
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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
67b0398b8c
commit
5ddf6ce0cf
@@ -6,12 +6,16 @@ export const createCase = async (req: AuthenticatedRequest, res: Response) => {
|
|||||||
try {
|
try {
|
||||||
const userId = req.user?.id;
|
const userId = req.user?.id;
|
||||||
const title = String(req.body?.title || 'Yeni Sohbet').slice(0, 200);
|
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
|
// 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
|
// 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.
|
// ile) yapılıyor, cases için de RLS engeli yaşanmasın diye.
|
||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from('cases')
|
.from('cases')
|
||||||
.insert([{ title, user_id: userId }])
|
.insert([{ title, user_id: userId, kind }])
|
||||||
.select('id, title')
|
.select('id, title')
|
||||||
.single();
|
.single();
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
|
|||||||
Reference in New Issue
Block a user