* Calendar/CalDAV: Thunderbird and CalDAVSynchronizer: update only participant data, instead of failing when the event was changed

This commit is contained in:
ralf 2023-08-10 15:11:35 +02:00
parent ccef28d192
commit 2da6961dcb
2 changed files with 26 additions and 8 deletions

View File

@ -286,9 +286,10 @@ abstract class Handler
* @param int|string& $id on return self::$path_extension got removed
* @param boolean& $return_no_access =false if set to true on call, instead of '403 Forbidden' the entry is returned and $return_no_access===false
* @param boolean $ignore_if_match =false if true, ignore If-Match precondition
* @param boolean $check_return_representation =true if true, checking for Prefer: return=representation and output it, false: no check
* @return array|string entry on success, string with http-error-code on failure, null for PUT on an unknown id
*/
function _common_get_put_delete($method,&$options,&$id,&$return_no_access=false,$ignore_if_match=false)
function _common_get_put_delete($method,&$options,&$id,&$return_no_access=false,$ignore_if_match=false,$check_return_representation=true)
{
if (self::$path_extension) $id = basename($id,self::$path_extension);
@ -327,7 +328,7 @@ abstract class Handler
{
if ($this->debug) error_log(__METHOD__."($method,path=$options[path],$id) HTTP_IF_MATCH='$_SERVER[HTTP_IF_MATCH]', etag='$etag': 412 Precondition failed".array2string($entry));
// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
$this->check_return_representation($options, $id);
if ($check_return_representation) $this->check_return_representation($options, $id);
return '412 Precondition Failed';
}
}
@ -347,7 +348,7 @@ abstract class Handler
{
if ($this->debug) error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 412 Precondition failed");
// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
$this->check_return_representation($options, $id);
if ($check_return_representation) $this->check_return_representation($options, $id);
return '412 Precondition Failed';
}
}
@ -460,8 +461,8 @@ abstract class Handler
'neon' => 'neon',
'ical4ol' => 'ical4ol', // iCal4OL client
'evolution' => 'evolution', // Evolution
'thunderbird' => 'thunderbird', // SOGo connector for addressbook, no Lightning installed
'caldavsynchronizer'=> 'caldavsynchronizer', // Outlook CalDAV Synchroniser (https://caldavsynchronizer.org/)
'thunderbird' => 'thunderbird', // Thunderbird 115+ (no extra Lightning) or SOGo connector for addressbook, no Lightning installed
'caldavsynchronizer'=> 'caldavsynchronizer', // Outlook CalDAV Synchronizer (https://caldavsynchronizer.org/)
'davx5' => 'davx5', // DAVx5 (https://www.davx5.com/)
) as $pattern => $name)
{

View File

@ -1011,14 +1011,29 @@ class calendar_groupdav extends Api\CalDAV\Handler
{
$_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'] = $_SERVER['HTTP_IF_SCHEDULE'];
}
// Thunderbird or Lightning: for "412 Precondition Failed" update only participant data, as TB offers user to overwrite server state
// CalDAVSynchronizer: does NOT handle 412 well and fails the complete sync, updating participant data only is the better option
$handle_etag_failure_with_partial_update = in_array(self::get_agent(), ['thunderbird', 'lightning', 'caldavsynchronizer']);
$return_no_access = true; // as handled by importVCal anyway and allows it to set the status for participants
$oldEvent = $this->_common_get_put_delete('PUT',$options,$id,$return_no_access,
isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])); // dont fail with 412 Precondition Failed in that case
if (!is_null($oldEvent) && !is_array($oldEvent))
isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']), !$handle_etag_failure_with_partial_update); // dont fail with 412 Precondition Failed in that case
if ($oldEvent === '412 Precondition Failed' && $handle_etag_failure_with_partial_update)
{
$oldEvent = $this->read($id);
$this->caldav->log("Handing 412 Precondition Failed for Thunderbird by only updating participant data!");
}
elseif (!is_null($oldEvent) && !is_array($oldEvent))
{
if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace());
return $oldEvent;
}
else
{
// set it to false, as we have no precondition failure
$handle_etag_failure_with_partial_update = false;
}
if (is_null($oldEvent) && ($user >= 0 && !$this->bo->check_perms(Acl::ADD, 0, $user) ||
// if we require an extra invite grant, we fail if that does not exist (bind privilege is not given in that case)
@ -1080,7 +1095,7 @@ class calendar_groupdav extends Api\CalDAV\Handler
if ($schedule_tag_match !== $schedule_tag)
{
if ($this->debug) error_log(__METHOD__."(,,$user) schedule_tag missmatch: given '$schedule_tag_match' != '$schedule_tag'");
if ($this->debug) error_log(__METHOD__."(,,$user) schedule_tag mismatch: given '$schedule_tag_match' != '$schedule_tag'");
// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
$this->check_return_representation($options, $id, $user);
return '412 Precondition Failed';
@ -1088,6 +1103,8 @@ class calendar_groupdav extends Api\CalDAV\Handler
}
// if no edit-rights (aka no organizer), update only attendee stuff: status and alarms
if (!$this->check_access(Acl::EDIT, $oldEvent) ||
// only update participant data, if precondition is NOT meet
$handle_etag_failure_with_partial_update ||
// we ignored Lightings If-None-Match: "*" --> do not overwrite event, just change status
!empty($workaround_lightning_if_none_match))
{