Skip to content

Commit aa1551d

Browse files
committed
fix: new OG case from new form submission
1 parent 435908d commit aa1551d

File tree

1 file changed

+18
-1
lines changed
  • packages/backend/src/apps/gathersg/auth

1 file changed

+18
-1
lines changed

packages/backend/src/apps/gathersg/auth/schema.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,16 @@ const schema = z
1919
name: z.string().min(1).optional(),
2020
})
2121
.optional(),
22+
formsg: z
23+
.object({
24+
formId: z.string().min(1),
25+
submissionId: z.string().min(1),
26+
})
27+
.optional(),
2228
})
2329
.refine(
2430
(data) => {
25-
const { updatedBy, createdBy } = data || {}
31+
const { updatedBy, createdBy, formsg } = data || {}
2632

2733
// if both updatedBy and createdBy exist, only check updatedBy.email
2834
if (updatedBy && createdBy) {
@@ -36,6 +42,17 @@ const schema = z
3642

3743
// if only createdBy exists, check for createdBy.email
3844
if (createdBy) {
45+
// when the createdBy.name is 'FormSG', there will not be a createdBy.email
46+
// as the case is created by a FormSG submission.
47+
if (
48+
createdBy?.name === 'FormSG' &&
49+
formsg?.formId &&
50+
formsg?.submissionId
51+
) {
52+
return true
53+
}
54+
55+
// otherwise, check for createdBy.email
3956
return !!createdBy.email
4057
}
4158

0 commit comments

Comments
 (0)