Skip to content

Commit

Permalink
fix(be): sdk flow detail ignore org limit (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
VojtechVidra committed Apr 17, 2024
1 parent 1643c75 commit 4373339
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
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

0 comments on commit 4373339

Please sign in to comment.