fix: use updateCalendarObject instead of updateObject for CalDAV updates
iCloud returned 501 Not Implemented for updateObject calls. Switch to updateCalendarObject which properly sends CalDAV PUT requests. Fixed in both Apple Calendar and Synology Calendar update + recurring delete paths. v1.71.1 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
da2ebbedb5
commit
e1e31cef20
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "my-weekly-todo-list",
|
"name": "my-weekly-todo-list",
|
||||||
"version": "1.71.0",
|
"version": "1.71.1",
|
||||||
"description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view",
|
"description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -818,32 +818,17 @@ export const updateEvent = async (
|
|||||||
const updatedIcalString = comp.toString();
|
const updatedIcalString = comp.toString();
|
||||||
console.log('[APPLE CALENDAR] Updating event with iCal:', updatedIcalString);
|
console.log('[APPLE CALENDAR] Updating event with iCal:', updatedIcalString);
|
||||||
|
|
||||||
// tsdav types might be slightly off in the d.ts compared to usage or we need to check the actual signature
|
// Use updateCalendarObject with the modified calendar object
|
||||||
// In d.ts: updateCalendarObject(params: { calendarObject: DAVCalendarObject ... }) -> Promise<Response>
|
const updateResult = await client.updateCalendarObject({
|
||||||
// But it doesn't seem to take 'data' in the d.ts signature shown earlier?
|
calendarObject: {
|
||||||
// Wait, let's look at d.ts again.
|
...targetObject,
|
||||||
// updateCalendarObject: (params: { calendarObject: ..., headers?: ... })
|
data: updatedIcalString,
|
||||||
// It DOES NOT show `data` or `etag` in the params in the d.ts signature shown earlier?
|
},
|
||||||
// Let's check line 117 of d.ts:
|
});
|
||||||
// updateCalendarObject: (params: { calendarObject: ... })
|
|
||||||
// This implies the data must be SET on the calendarObject before calling?
|
|
||||||
// OR the d.ts is incomplete/wrong.
|
|
||||||
|
|
||||||
// Let's assume we need to update the object locally then call update?
|
// Check for errors in the response
|
||||||
// Or maybe we use the `davRequest` or `updateObject` lower level if `updateCalendarObject` limits us.
|
const status = (updateResult as any)?.status || (updateResult as any)?.ok;
|
||||||
// Actually, `updateObject` takes `url`, `data`, `etag`.
|
if (updateResult && typeof (updateResult as any).status === 'number' && (updateResult as any).status >= 400) {
|
||||||
|
|
||||||
// Let's try using `client.updateObject` directly which is more raw but allows data.
|
|
||||||
// `targetObject.url` is what we need.
|
|
||||||
|
|
||||||
const updateResult = await client.updateObject({
|
|
||||||
url: targetObject.url,
|
|
||||||
data: updatedIcalString,
|
|
||||||
etag: targetObject.etag
|
|
||||||
} as any); // Cast to any to bypass type definition mismatch
|
|
||||||
|
|
||||||
// Log result for debugging
|
|
||||||
if (updateResult && (updateResult as any).status && (updateResult as any).status >= 400) {
|
|
||||||
console.error('[APPLE CALENDAR] Update failed with status:', (updateResult as any).status);
|
console.error('[APPLE CALENDAR] Update failed with status:', (updateResult as any).status);
|
||||||
throw new Error(`CalDAV update failed with status ${(updateResult as any).status}`);
|
throw new Error(`CalDAV update failed with status ${(updateResult as any).status}`);
|
||||||
}
|
}
|
||||||
@ -1032,11 +1017,13 @@ export const deleteRecurringInstance = async (
|
|||||||
|
|
||||||
// PUT the modified object back
|
// PUT the modified object back
|
||||||
const updatedData = comp.toString();
|
const updatedData = comp.toString();
|
||||||
await client.updateObject({
|
await client.updateCalendarObject({
|
||||||
url: objectUrl,
|
calendarObject: {
|
||||||
data: updatedData,
|
...targetObject,
|
||||||
etag: targetObject.etag,
|
url: objectUrl,
|
||||||
} as any);
|
data: updatedData,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
console.log('[APPLE CALENDAR] Recurring instance delete complete (mode:', deleteMode, ')');
|
console.log('[APPLE CALENDAR] Recurring instance delete complete (mode:', deleteMode, ')');
|
||||||
|
|
||||||
|
|||||||
@ -820,11 +820,12 @@ export const updateEvent = async (
|
|||||||
const updatedIcalString = comp.toString();
|
const updatedIcalString = comp.toString();
|
||||||
console.log('[SYNOLOGY CALENDAR] Updating event with iCal:', updatedIcalString);
|
console.log('[SYNOLOGY CALENDAR] Updating event with iCal:', updatedIcalString);
|
||||||
|
|
||||||
await client.updateObject({
|
await client.updateCalendarObject({
|
||||||
url: targetObject.url,
|
calendarObject: {
|
||||||
data: updatedIcalString,
|
...targetObject,
|
||||||
etag: targetObject.etag
|
data: updatedIcalString,
|
||||||
} as any);
|
},
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: eventId,
|
id: eventId,
|
||||||
@ -994,11 +995,13 @@ export const deleteRecurringInstance = async (
|
|||||||
|
|
||||||
// PUT the modified object back
|
// PUT the modified object back
|
||||||
const updatedData = comp.toString();
|
const updatedData = comp.toString();
|
||||||
await client.updateObject({
|
await client.updateCalendarObject({
|
||||||
url: objectUrl,
|
calendarObject: {
|
||||||
data: updatedData,
|
...targetObject,
|
||||||
etag: targetObject.etag,
|
url: objectUrl,
|
||||||
} as any);
|
data: updatedData,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
console.log('[SYNOLOGY CALENDAR] Recurring instance delete complete (mode:', deleteMode, ')');
|
console.log('[SYNOLOGY CALENDAR] Recurring instance delete complete (mode:', deleteMode, ')');
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user