mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-19 06:04:05 +00:00
fix change api isPublic (#1008)
This commit is contained in:
committed by
GitHub
parent
345ea6722e
commit
9d04954d87
@@ -47,8 +47,8 @@ const actionHandlers: Record<string, ActionHandler> = {
|
|||||||
if (typeof property !== 'string' || value === undefined) {
|
if (typeof property !== 'string' || value === undefined) {
|
||||||
throw new Error('Invalid property or value');
|
throw new Error('Invalid property or value');
|
||||||
}
|
}
|
||||||
// all custom fields keys are lowercase
|
|
||||||
const newObjectProperty = parseProperty(property.toLowerCase(), value);
|
const newObjectProperty = parseProperty(property, value);
|
||||||
|
|
||||||
if (patchEvent.custom && newObjectProperty.custom) {
|
if (patchEvent.custom && newObjectProperty.custom) {
|
||||||
Object.assign(patchEvent.custom, newObjectProperty.custom);
|
Object.assign(patchEvent.custom, newObjectProperty.custom);
|
||||||
|
|||||||
@@ -23,14 +23,13 @@ const whitelistedPayload = {
|
|||||||
|
|
||||||
export function parseProperty(property: string, value: unknown) {
|
export function parseProperty(property: string, value: unknown) {
|
||||||
if (property.startsWith('custom:')) {
|
if (property.startsWith('custom:')) {
|
||||||
const customKey = property.split(':')[1];
|
const customKey = property.split(':')[1].toLocaleLowerCase(); // all custom fields keys are lowercase
|
||||||
if (!(customKey in DataProvider.getCustomFields())) {
|
if (!(customKey in DataProvider.getCustomFields())) {
|
||||||
throw new Error(`Custom field ${customKey} not found`);
|
throw new Error(`Custom field ${customKey} not found`);
|
||||||
}
|
}
|
||||||
const parserFn = whitelistedPayload.custom;
|
const parserFn = whitelistedPayload.custom;
|
||||||
return { custom: { [customKey]: parserFn(value) } };
|
return { custom: { [customKey]: parserFn(value) } };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isKeyOfType(property, whitelistedPayload)) {
|
if (!isKeyOfType(property, whitelistedPayload)) {
|
||||||
throw new Error(`Property ${property} not permitted`);
|
throw new Error(`Property ${property} not permitted`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user