1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-08-01 18:18:31 +00:00

- Include legacy "content" parameter in HookNotificationItem usage

This commit is contained in:
Nate Harris 2025-07-19 23:29:18 -06:00
parent 5922cc04e3
commit 070ba2d603
3 changed files with 22 additions and 19 deletions

View file

@ -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,

View file

@ -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:

View file

@ -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