File tree Expand file tree Collapse file tree 2 files changed +40
-2
lines changed
packages/backend/src/apps/gathersg Expand file tree Collapse file tree 2 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -308,5 +308,39 @@ describe('gathersg auth schema', () => {
308308 } )
309309 expect ( result . success ) . toBe ( false )
310310 } )
311+
312+ it ( 'rejects Workflow updatedBy without createdBy' , ( ) => {
313+ const result = schema . safeParse ( {
314+ updatedBy : {
315+ name : 'Workflow' ,
316+ } ,
317+ } )
318+ expect ( result . success ) . toBe ( false )
319+ } )
320+
321+ it ( 'rejects Workflow updatedBy when createdBy is missing email' , ( ) => {
322+ const result = schema . safeParse ( {
323+ updatedBy : {
324+ name : 'Workflow' ,
325+ } ,
326+ createdBy : {
327+ name : 'Creator' ,
328+ } ,
329+ } )
330+ expect ( result . success ) . toBe ( false )
331+ } )
332+
333+ it ( 'rejects Workflow updatedBy when createdBy email is null' , ( ) => {
334+ const result = schema . safeParse ( {
335+ updatedBy : {
336+ name : 'Workflow' ,
337+ } ,
338+ createdBy : {
339+ email : null ,
340+ name : 'Creator' ,
341+ } ,
342+ } )
343+ expect ( result . success ) . toBe ( false )
344+ } )
311345 } )
312346} )
Original file line number Diff line number Diff line change @@ -36,15 +36,19 @@ const schema = z
3636 if ( updatedBy . name === 'Workflow' ) {
3737 /**
3838 * SPECIAL CASE
39- * if the workflow had an update step before sending the webhook,
39+ * if the workflow has an update step before calling the webhook,
4040 * the webhook will return with:
4141 * {
4242 * updatedBy: {
4343 * name: 'Workflow',
4444 * },
4545 * }
46+ *
47+ * Best effort check that createdBy must contain both email and name
48+ * to know that its not an API creating the case and an instant workflow
49+ * calling Plumber again.
4650 */
47- return ! updatedBy . email
51+ return ! updatedBy . email && ! ! createdBy ?. email && ! ! createdBy ?. name
4852 }
4953 return ! ! updatedBy . email
5054 }
You can’t perform that action at this time.
0 commit comments