Browse Source

fix: webhook validation for user fields

pull/9422/head
DarkPhoenix2704 3 months ago
parent
commit
8d295550f9
  1. 39
      packages/nocodb/src/helpers/webhookHelpers.ts

39
packages/nocodb/src/helpers/webhookHelpers.ts

@ -227,6 +227,44 @@ export async function validateCondition(
break;
}
if (
[UITypes.User, UITypes.CreatedBy, UITypes.LastModifiedBy].includes(
column.uidt,
)
) {
const userIds = Array.isArray(data[field])
? data[field].map((user) => user.id)
: data[field]?.id
? [data[field].id]
: [];
const filterValues = filter.value.split(',').map((v) => v.trim());
switch (filter.comparison_op) {
case 'anyof':
res = userIds.some((id) => filterValues.includes(id));
break;
case 'nanyof':
res = !userIds.some((id) => filterValues.includes(id));
break;
case 'allof':
res = filterValues.every((id) => userIds.includes(id));
break;
case 'nallof':
res = !filterValues.every((id) => userIds.includes(id));
break;
case 'empty':
case 'blank':
res = userIds.length === 0;
break;
case 'notempty':
case 'notblank':
res = userIds.length > 0;
break;
default:
res = false; // Unsupported operation for User fields
}
} else {
switch (filter.comparison_op) {
case 'eq':
res = val == filter.value;
@ -312,6 +350,7 @@ export async function validateCondition(
}
}
}
}
switch (filter.logical_op) {
case 'or':

Loading…
Cancel
Save