From 070ba2d603adfaf296a655ea940c1504192ae101 Mon Sep 17 00:00:00 2001 From: Nate Harris Date: Sat, 19 Jul 2025 23:29:18 -0600 Subject: [PATCH] - Include legacy "content" parameter in HookNotificationItem usage --- radicale/app/delete.py | 2 ++ radicale/app/proppatch.py | 12 ++++++++---- radicale/app/put.py | 27 ++++++++++++--------------- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/radicale/app/delete.py b/radicale/app/delete.py index 46b90702..5ee7c434 100644 --- a/radicale/app/delete.py +++ b/radicale/app/delete.py @@ -85,6 +85,7 @@ class ApplicationPartDelete(ApplicationBase): HookNotificationItem( notification_item_type=HookNotificationItemTypes.DELETE, path=access.path, + content=i.uid, uid=i.uid, old_content=item.serialize(), # type: ignore new_content=None @@ -98,6 +99,7 @@ class ApplicationPartDelete(ApplicationBase): HookNotificationItem( notification_item_type=HookNotificationItemTypes.DELETE, path=access.path, + content=item.uid, uid=item.uid, old_content=item.serialize(), # type: ignore new_content=None, diff --git a/radicale/app/proppatch.py b/radicale/app/proppatch.py index 1ff45763..67018f7f 100644 --- a/radicale/app/proppatch.py +++ b/radicale/app/proppatch.py @@ -101,13 +101,17 @@ class ApplicationPartProppatch(ApplicationBase): xml_answer = xml_proppatch(base_prefix, path, xml_content, item) if xml_content is not None: + content = DefusedET.tostring( + xml_content, + encoding=self._encoding + ).decode(encoding=self._encoding) hook_notification_item = HookNotificationItem( notification_item_type=HookNotificationItemTypes.CPATCH, path=access.path, - new_content=DefusedET.tostring( - xml_content, - encoding=self._encoding - ).decode(encoding=self._encoding) + content=content, + uid=None, + old_content=None, + new_content=content ) self._hook.notify(hook_notification_item) except ValueError as e: diff --git a/radicale/app/put.py b/radicale/app/put.py index 4df939b4..a38499ef 100644 --- a/radicale/app/put.py +++ b/radicale/app/put.py @@ -254,6 +254,8 @@ class ApplicationPartPut(ApplicationBase): hook_notification_item = HookNotificationItem( notification_item_type=HookNotificationItemTypes.UPSERT, path=access.path, + content=existing_item.serialize(), + uid=None, old_content=existing_item.serialize(), new_content=item.serialize() ) @@ -261,6 +263,8 @@ class ApplicationPartPut(ApplicationBase): hook_notification_item = HookNotificationItem( notification_item_type=HookNotificationItemTypes.UPSERT, path=access.path, + content=item.serialize(), + uid=None, old_content=None, new_content=item.serialize() ) @@ -282,21 +286,14 @@ class ApplicationPartPut(ApplicationBase): try: uploaded_item, replaced_item = parent_item.upload(href, prepared_item) etag = uploaded_item.etag - if replaced_item: - # If the item was replaced, we notify with the old content - hook_notification_item = HookNotificationItem( - notification_item_type=HookNotificationItemTypes.UPSERT, - path=access.path, - old_content=replaced_item.serialize(), - new_content=prepared_item.serialize() - ) - else: # If it was a new item, we notify with no old content - hook_notification_item = HookNotificationItem( - notification_item_type=HookNotificationItemTypes.UPSERT, - path=access.path, - old_content=None, - new_content=prepared_item.serialize() - ) + hook_notification_item = HookNotificationItem( + notification_item_type=HookNotificationItemTypes.UPSERT, + path=access.path, + content=prepared_item.serialize(), + uid=None, + old_content=replaced_item.serialize() if replaced_item else None, + new_content=prepared_item.serialize() + ) self._hook.notify(hook_notification_item) except ValueError as e: # return better matching HTTP result in case errno is provided and catched