refactor(ai): DRY saveAiSettings and enforce strict NOT_FOUND validation

This commit is contained in:
Yash Kumar
2026-09-21 02:48:26 +05:30
parent 0049421095
commit a9871f3a8d
+1 -9
View File
@@ -138,15 +138,7 @@ export const saveAiSettings = async (organizationId: string, settings: any) => {
const aiId = settings.aiId;
if (aiId) {
const existing = await db.query.ai.findFirst({
where: eq(ai.aiId, aiId),
});
if (existing && existing.organizationId !== organizationId) {
throw new TRPCError({
code: "FORBIDDEN",
message: "You do not have permission to modify this AI configuration",
});
}
await getAiSettingById(aiId, organizationId);
}
if (settings.apiUrl) {