mirror of
https://github.com/Kozea/Radicale.git
synced 2025-06-26 16:45:52 +00:00
Added hook to proppatch request
This commit is contained in:
parent
46d1a31441
commit
06fbac67a1
2 changed files with 11 additions and 0 deletions
|
@ -21,9 +21,12 @@ import socket
|
||||||
from http import client
|
from http import client
|
||||||
from xml.etree import ElementTree as ET
|
from xml.etree import ElementTree as ET
|
||||||
|
|
||||||
|
import defusedxml.ElementTree as DefusedET
|
||||||
|
|
||||||
from radicale import app, httputils
|
from radicale import app, httputils
|
||||||
from radicale import item as radicale_item
|
from radicale import item as radicale_item
|
||||||
from radicale import storage, xmlutils
|
from radicale import storage, xmlutils
|
||||||
|
from radicale.hook import HookNotificationItem, HookNotificationItemTypes
|
||||||
from radicale.log import logger
|
from radicale.log import logger
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,6 +115,13 @@ class ApplicationProppatchMixin:
|
||||||
try:
|
try:
|
||||||
xml_answer = xml_proppatch(base_prefix, path, xml_content,
|
xml_answer = xml_proppatch(base_prefix, path, xml_content,
|
||||||
item)
|
item)
|
||||||
|
hook_notification_item = HookNotificationItem(
|
||||||
|
HookNotificationItemTypes.CPATCH,
|
||||||
|
access.path,
|
||||||
|
DefusedET.tostring(xml_content, encoding=self._encoding)
|
||||||
|
.decode(encoding=self._encoding)
|
||||||
|
)
|
||||||
|
self._hook.notify(hook_notification_item)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Bad PROPPATCH request on %r: %s", path, e, exc_info=True)
|
"Bad PROPPATCH request on %r: %s", path, e, exc_info=True)
|
||||||
|
|
|
@ -29,6 +29,7 @@ class BaseHook:
|
||||||
|
|
||||||
|
|
||||||
class HookNotificationItemTypes(Enum):
|
class HookNotificationItemTypes(Enum):
|
||||||
|
CPATCH = "cpatch"
|
||||||
UPSERT = "upsert"
|
UPSERT = "upsert"
|
||||||
DELETE = "delete"
|
DELETE = "delete"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue