mirror of
https://github.com/Kozea/Radicale.git
synced 2025-08-01 18:18:31 +00:00
Improved notification message with user/calendar point as field
This commit is contained in:
parent
da31f80ba5
commit
bf5272e83d
3 changed files with 16 additions and 2 deletions
|
@ -69,6 +69,7 @@ class ApplicationDeleteMixin:
|
||||||
hook_notification_item_list.append(
|
hook_notification_item_list.append(
|
||||||
HookNotificationItem(
|
HookNotificationItem(
|
||||||
HookNotificationItemTypes.DELETE,
|
HookNotificationItemTypes.DELETE,
|
||||||
|
access.path,
|
||||||
i.uid
|
i.uid
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -77,6 +78,7 @@ class ApplicationDeleteMixin:
|
||||||
hook_notification_item_list.append(
|
hook_notification_item_list.append(
|
||||||
HookNotificationItem(
|
HookNotificationItem(
|
||||||
HookNotificationItemTypes.DELETE,
|
HookNotificationItemTypes.DELETE,
|
||||||
|
access.path,
|
||||||
item.uid
|
item.uid
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -197,6 +197,7 @@ class ApplicationPutMixin:
|
||||||
for item in prepared_items:
|
for item in prepared_items:
|
||||||
hook_notification_item = HookNotificationItem(
|
hook_notification_item = HookNotificationItem(
|
||||||
HookNotificationItemTypes.UPSERT,
|
HookNotificationItemTypes.UPSERT,
|
||||||
|
access.path,
|
||||||
item.serialize()
|
item.serialize()
|
||||||
)
|
)
|
||||||
self._hook.notify(hook_notification_item)
|
self._hook.notify(hook_notification_item)
|
||||||
|
@ -217,6 +218,7 @@ class ApplicationPutMixin:
|
||||||
etag = parent_item.upload(href, prepared_item).etag
|
etag = parent_item.upload(href, prepared_item).etag
|
||||||
hook_notification_item = HookNotificationItem(
|
hook_notification_item = HookNotificationItem(
|
||||||
HookNotificationItemTypes.UPSERT,
|
HookNotificationItemTypes.UPSERT,
|
||||||
|
access.path,
|
||||||
prepared_item.serialize()
|
prepared_item.serialize()
|
||||||
)
|
)
|
||||||
self._hook.notify(hook_notification_item)
|
self._hook.notify(hook_notification_item)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import json
|
import json
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
from radicale import utils
|
from radicale import pathutils, utils
|
||||||
|
|
||||||
INTERNAL_TYPES = ("none", "rabbitmq")
|
INTERNAL_TYPES = ("none", "rabbitmq")
|
||||||
|
|
||||||
|
@ -33,10 +33,20 @@ class HookNotificationItemTypes(Enum):
|
||||||
DELETE = "delete"
|
DELETE = "delete"
|
||||||
|
|
||||||
|
|
||||||
|
def _cleanup(path):
|
||||||
|
sane_path = pathutils.strip_path(path)
|
||||||
|
attributes = sane_path.split("/") if sane_path else []
|
||||||
|
|
||||||
|
if len(attributes) < 2:
|
||||||
|
return ""
|
||||||
|
return attributes[0] + "/" + attributes[1]
|
||||||
|
|
||||||
|
|
||||||
class HookNotificationItem:
|
class HookNotificationItem:
|
||||||
|
|
||||||
def __init__(self, notification_item_type, content):
|
def __init__(self, notification_item_type, path, content):
|
||||||
self.type = notification_item_type.value
|
self.type = notification_item_type.value
|
||||||
|
self.point = _cleanup(path)
|
||||||
self.content = content
|
self.content = content
|
||||||
|
|
||||||
def to_json(self):
|
def to_json(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue