Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(be): sdk flow detail ignore org limit #258

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions apps/backend/src/sdk/sdk.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,10 @@ describe("Get flow detail", () => {
"Not Allowed",
);
});
it("should return no flows when limit is reached", async () => {
organizationUsageService.getIsOrganizationLimitReachedByProject.mockResolvedValue(true);
await expect(sdkController.getFlowDetail("origin", "projectId", "flowId")).rejects.toThrow(
"Organization limit reached",
);
});
it("should throw without flow", async () => {
db.query.flows.findFirst.mockReturnValue(null);
await expect(sdkController.getFlowDetail("origin", "projectId", "flowId")).rejects.toThrow(
"Bad Request",
"Not Found",
);
expect(db.query.flows.findFirst).toHaveBeenCalled();
});
Expand Down
9 changes: 3 additions & 6 deletions apps/backend/src/sdk/sdk.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@ export class SdkService {
if (!flowId) throw new NotFoundException();
await this.dbPermissionService.isAllowedOrigin({ projectId, requestOrigin });

const limitReached = await this.organizationUsageService.getIsOrganizationLimitReachedByProject(
{ projectId },
);
if (limitReached) throw new BadRequestException("Organization limit reached");

const flow = await this.databaseService.db.query.flows.findFirst({
where: and(
eq(flows.project_id, projectId),
Expand All @@ -161,7 +156,9 @@ export class SdkService {
),
with: { publishedVersion: true },
});
if (!flow?.publishedVersion) throw new BadRequestException();
if (!flow) throw new NotFoundException();
if (!flow.publishedVersion) throw new BadRequestException();

const data = flow.publishedVersion.data;
return {
id: flow.human_id,
Expand Down