* REST Api: allow to create new fields with PATCH for application/json content-type and error on not existing custom fields

This commit is contained in:
ralf 2024-01-08 09:41:43 +02:00
parent 543fb4d342
commit 94670fcf83
3 changed files with 6 additions and 6 deletions

View File

@ -236,10 +236,10 @@ class JsBase
$contact['#'.$name] = null;
}
}
// report not existing cfs to log
// error not existing cfs
if (($not_existing=array_diff(array_keys($cfs), array_keys($definitions))))
{
error_log(__METHOD__."() not existing/ignored custom fields: ".implode(', ', $not_existing));
throw new JsParseException("Trying to update not existing custom field(s): ".implode(', ', $not_existing));
}
return $contact;
}

View File

@ -110,8 +110,8 @@ class JsCalendar extends JsBase
return strpos($key, '/') !== false;
}))
{
// apply patch on JsCard of contact
$data = self::patch($data, $old ? self::getJsCalendar($old, false) : [], !$old);
// apply patch on JsEvent
$data = self::patch($data, $old ? self::getJsCalendar($old, false) : [], !$old || !$strict);
}
if (!isset($data['uid'])) $data['uid'] = null; // to fail below, if it does not exist

View File

@ -104,7 +104,7 @@ class JsContact extends Api\CalDAV\JsBase
}))
{
// apply patch on JsCard of contact
$data = self::patch($data, $old ? self::getJsCard($old, false) : [], !$old);
$data = self::patch($data, $old ? self::getJsCard($old, false) : [], !$old || !$strict);
}
if (!isset($data['uid'])) $data['uid'] = null; // to fail below, if it does not exist
@ -188,7 +188,7 @@ class JsContact extends Api\CalDAV\JsBase
break;
case 'egroupware.org:customfields':
$contact += self::parseCustomfields($value, $strict);
$contact += self::parseCustomfields($value);
break;
case 'egroupware.org:assistant':