mirror of
https://github.com/Kozea/Radicale.git
synced 2025-08-04 18:22:26 +00:00
- Include legacy "content" parameter in HookNotificationItem usage
This commit is contained in:
parent
5922cc04e3
commit
070ba2d603
3 changed files with 22 additions and 19 deletions
|
@ -85,6 +85,7 @@ class ApplicationPartDelete(ApplicationBase):
|
||||||
HookNotificationItem(
|
HookNotificationItem(
|
||||||
notification_item_type=HookNotificationItemTypes.DELETE,
|
notification_item_type=HookNotificationItemTypes.DELETE,
|
||||||
path=access.path,
|
path=access.path,
|
||||||
|
content=i.uid,
|
||||||
uid=i.uid,
|
uid=i.uid,
|
||||||
old_content=item.serialize(), # type: ignore
|
old_content=item.serialize(), # type: ignore
|
||||||
new_content=None
|
new_content=None
|
||||||
|
@ -98,6 +99,7 @@ class ApplicationPartDelete(ApplicationBase):
|
||||||
HookNotificationItem(
|
HookNotificationItem(
|
||||||
notification_item_type=HookNotificationItemTypes.DELETE,
|
notification_item_type=HookNotificationItemTypes.DELETE,
|
||||||
path=access.path,
|
path=access.path,
|
||||||
|
content=item.uid,
|
||||||
uid=item.uid,
|
uid=item.uid,
|
||||||
old_content=item.serialize(), # type: ignore
|
old_content=item.serialize(), # type: ignore
|
||||||
new_content=None,
|
new_content=None,
|
||||||
|
|
|
@ -101,13 +101,17 @@ class ApplicationPartProppatch(ApplicationBase):
|
||||||
xml_answer = xml_proppatch(base_prefix, path, xml_content,
|
xml_answer = xml_proppatch(base_prefix, path, xml_content,
|
||||||
item)
|
item)
|
||||||
if xml_content is not None:
|
if xml_content is not None:
|
||||||
|
content = DefusedET.tostring(
|
||||||
|
xml_content,
|
||||||
|
encoding=self._encoding
|
||||||
|
).decode(encoding=self._encoding)
|
||||||
hook_notification_item = HookNotificationItem(
|
hook_notification_item = HookNotificationItem(
|
||||||
notification_item_type=HookNotificationItemTypes.CPATCH,
|
notification_item_type=HookNotificationItemTypes.CPATCH,
|
||||||
path=access.path,
|
path=access.path,
|
||||||
new_content=DefusedET.tostring(
|
content=content,
|
||||||
xml_content,
|
uid=None,
|
||||||
encoding=self._encoding
|
old_content=None,
|
||||||
).decode(encoding=self._encoding)
|
new_content=content
|
||||||
)
|
)
|
||||||
self._hook.notify(hook_notification_item)
|
self._hook.notify(hook_notification_item)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
|
|
|
@ -254,6 +254,8 @@ class ApplicationPartPut(ApplicationBase):
|
||||||
hook_notification_item = HookNotificationItem(
|
hook_notification_item = HookNotificationItem(
|
||||||
notification_item_type=HookNotificationItemTypes.UPSERT,
|
notification_item_type=HookNotificationItemTypes.UPSERT,
|
||||||
path=access.path,
|
path=access.path,
|
||||||
|
content=existing_item.serialize(),
|
||||||
|
uid=None,
|
||||||
old_content=existing_item.serialize(),
|
old_content=existing_item.serialize(),
|
||||||
new_content=item.serialize()
|
new_content=item.serialize()
|
||||||
)
|
)
|
||||||
|
@ -261,6 +263,8 @@ class ApplicationPartPut(ApplicationBase):
|
||||||
hook_notification_item = HookNotificationItem(
|
hook_notification_item = HookNotificationItem(
|
||||||
notification_item_type=HookNotificationItemTypes.UPSERT,
|
notification_item_type=HookNotificationItemTypes.UPSERT,
|
||||||
path=access.path,
|
path=access.path,
|
||||||
|
content=item.serialize(),
|
||||||
|
uid=None,
|
||||||
old_content=None,
|
old_content=None,
|
||||||
new_content=item.serialize()
|
new_content=item.serialize()
|
||||||
)
|
)
|
||||||
|
@ -282,21 +286,14 @@ class ApplicationPartPut(ApplicationBase):
|
||||||
try:
|
try:
|
||||||
uploaded_item, replaced_item = parent_item.upload(href, prepared_item)
|
uploaded_item, replaced_item = parent_item.upload(href, prepared_item)
|
||||||
etag = uploaded_item.etag
|
etag = uploaded_item.etag
|
||||||
if replaced_item:
|
hook_notification_item = HookNotificationItem(
|
||||||
# If the item was replaced, we notify with the old content
|
notification_item_type=HookNotificationItemTypes.UPSERT,
|
||||||
hook_notification_item = HookNotificationItem(
|
path=access.path,
|
||||||
notification_item_type=HookNotificationItemTypes.UPSERT,
|
content=prepared_item.serialize(),
|
||||||
path=access.path,
|
uid=None,
|
||||||
old_content=replaced_item.serialize(),
|
old_content=replaced_item.serialize() if replaced_item else None,
|
||||||
new_content=prepared_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()
|
|
||||||
)
|
|
||||||
self._hook.notify(hook_notification_item)
|
self._hook.notify(hook_notification_item)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
# return better matching HTTP result in case errno is provided and catched
|
# return better matching HTTP result in case errno is provided and catched
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue