mirror of
https://github.com/formbricks/formbricks.git
synced 2025-12-25 07:50:19 -06:00
Compare commits
5 Commits
4.2.0
...
hmaan-disp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
249e42b087 | ||
|
|
9ec4f22b1f | ||
|
|
ea00dec8e5 | ||
|
|
70cd751b0e | ||
|
|
4308d86bbc |
@@ -1,6 +1,7 @@
|
||||
import { responses } from "@/app/lib/api/response";
|
||||
import { transformErrorToDetails } from "@/app/lib/api/validator";
|
||||
import { sendToPipeline } from "@/app/lib/pipelines";
|
||||
import { getDisplay } from "@/lib/display/service";
|
||||
import { validateFileUploads } from "@/lib/fileValidation";
|
||||
import { capturePosthogEnvironmentEvent } from "@/lib/posthogServer";
|
||||
import { getSurvey } from "@/lib/survey/service";
|
||||
@@ -97,6 +98,14 @@ export const POST = async (request: Request, context: Context): Promise<Response
|
||||
return responses.badRequestResponse("Invalid file upload response");
|
||||
}
|
||||
|
||||
// check display
|
||||
if (responseInputData.displayId) {
|
||||
const display = await getDisplay(responseInputData.displayId);
|
||||
if (!display) {
|
||||
return responses.notFoundResponse("Display", responseInputData.displayId, true);
|
||||
}
|
||||
}
|
||||
|
||||
let response: TResponse;
|
||||
try {
|
||||
const meta: TResponseInput["meta"] = {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { checkSurveyValidity } from "@/app/api/v2/client/[environmentId]/respons
|
||||
import { responses } from "@/app/lib/api/response";
|
||||
import { transformErrorToDetails } from "@/app/lib/api/validator";
|
||||
import { sendToPipeline } from "@/app/lib/pipelines";
|
||||
import { getDisplay } from "@/lib/display/service";
|
||||
import { capturePosthogEnvironmentEvent } from "@/lib/posthogServer";
|
||||
import { getSurvey } from "@/lib/survey/service";
|
||||
import { validateOtherOptionLengthForMultipleChoice } from "@/modules/api/v2/lib/question";
|
||||
@@ -104,6 +105,14 @@ export const POST = async (request: Request, context: Context): Promise<Response
|
||||
);
|
||||
}
|
||||
|
||||
// check display
|
||||
if (responseInputData.displayId) {
|
||||
const display = await getDisplay(responseInputData.displayId);
|
||||
if (!display) {
|
||||
return responses.notFoundResponse("Display", responseInputData.displayId, true);
|
||||
}
|
||||
}
|
||||
|
||||
let response: TResponse;
|
||||
try {
|
||||
const meta: TResponseInputV2["meta"] = {
|
||||
|
||||
@@ -62,3 +62,19 @@ export const deleteDisplay = async (displayId: string): Promise<TDisplay> => {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const getDisplay = reactCache(async (displayId: string): Promise<{ id: string } | null> => {
|
||||
validateInputs([displayId, ZId]);
|
||||
try {
|
||||
const display = await prisma.display.findUnique({
|
||||
where: { id: displayId },
|
||||
select: { id: true },
|
||||
});
|
||||
return display;
|
||||
} catch (error) {
|
||||
if (error instanceof Prisma.PrismaClientKnownRequestError) {
|
||||
throw new DatabaseError(error.message);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -297,7 +297,7 @@ export const ZResponseInput = z.object({
|
||||
environmentId: z.string().cuid2(),
|
||||
surveyId: z.string().cuid2(),
|
||||
userId: z.string().nullish(),
|
||||
displayId: z.string().nullish(),
|
||||
displayId: z.string().cuid2().nullish(),
|
||||
singleUseId: z.string().nullable().optional(),
|
||||
finished: z.boolean(),
|
||||
endingId: z.string().nullish(),
|
||||
|
||||
Reference in New Issue
Block a user