Skip to content

Commit 0c4aeec

Browse files
committed
refactor, dont need extra function
1 parent c2a0dc3 commit 0c4aeec

File tree

1 file changed

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

1 file changed

+14
-18
lines changed

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

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
import { z } from 'zod'
22

3-
function validateUpdatedBy(updatedBy: { email?: string; name?: string }) {
4-
/**
5-
* SPECIAL CASE
6-
* if the workflow had an update step before sending the webhook,
7-
* the webhook will return with:
8-
* {
9-
* updatedBy: {
10-
* name: 'Workflow',
11-
* },
12-
* }
13-
*/
14-
if (updatedBy.name === 'Workflow') {
15-
return !updatedBy.email
16-
}
17-
return !!updatedBy.email
18-
}
19-
203
/**
214
* check for potential infinite loop
225
* if the webhook is not triggered by a user, it will not contain
@@ -50,7 +33,20 @@ const schema = z
5033

5134
// if updatedBy exists, check updatedBy first
5235
if (updatedBy) {
53-
return validateUpdatedBy(updatedBy)
36+
if (updatedBy.name === 'Workflow') {
37+
/**
38+
* SPECIAL CASE
39+
* if the workflow had an update step before sending the webhook,
40+
* the webhook will return with:
41+
* {
42+
* updatedBy: {
43+
* name: 'Workflow',
44+
* },
45+
* }
46+
*/
47+
return !updatedBy.email
48+
}
49+
return !!updatedBy.email
5450
}
5551

5652
// if only createdBy exists, check for createdBy.email

0 commit comments

Comments
 (0)