Skip to content

Commit

Permalink
콘텐츠 최신화 플랜 제한 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-maki committed Nov 18, 2024
1 parent 3ca447e commit 99724cf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
16 changes: 15 additions & 1 deletion apps/api/src/graphql/uptodate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { and, asc, cosineDistance, eq } from 'drizzle-orm';
import { uniqueBy } from 'remeda';
import { z } from 'zod';
import { builder } from '@/builder';
import { db, PageContentChunks, PageContents, Pages } from '@/db';
import { db, firstOrThrow, PageContentChunks, PageContents, Pages, Sites } from '@/db';
import { PageState } from '@/enums';
import * as langchain from '@/external/langchain';
import { fixByChangePrompt, keywordExtractionPrompt } from '@/prompt/fix-by-change';
import { assertSitePermission } from '@/utils/permissions';
import { assertTeamPlanRule } from '@/utils/plan';
import { Page } from './objects';

type FindOutdatedContent = {
Expand Down Expand Up @@ -56,6 +57,19 @@ builder.queryFields((t) => ({
userId: ctx.session.userId,
});

const site = await db
.select({
teamId: Sites.teamId,
})
.from(Sites)
.where(eq(Sites.id, args.siteId))
.then(firstOrThrow);

await assertTeamPlanRule({
teamId: site.teamId,
rule: 'aiSearch',
});

const chain1 = RunnableSequence.from([
ChatPromptTemplate.fromMessages([
['system', keywordExtractionPrompt],
Expand Down
7 changes: 7 additions & 0 deletions apps/api/src/utils/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,12 @@ export const assertTeamPlanRule = async <T extends keyof PlanRules>(params: GetP
}
break;
}

default: {
if (!value) {
throw new ReadableError({ code: 'feature_not_available' });
}
break;
}
}
};

0 comments on commit 99724cf

Please sign in to comment.