mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-14 15:15:22 +03:00
Listen to notification config updates
This commit is contained in:
parent
db5426570d
commit
d9f68db404
@ -9,6 +9,7 @@ from typing import Any, Callable
|
|||||||
from py_vapid import Vapid01
|
from py_vapid import Vapid01
|
||||||
from pywebpush import WebPusher
|
from pywebpush import WebPusher
|
||||||
|
|
||||||
|
from frigate.comms.config_updater import ConfigSubscriber
|
||||||
from frigate.comms.dispatcher import Communicator
|
from frigate.comms.dispatcher import Communicator
|
||||||
from frigate.config import FrigateConfig
|
from frigate.config import FrigateConfig
|
||||||
from frigate.const import CONFIG_DIR
|
from frigate.const import CONFIG_DIR
|
||||||
@ -41,6 +42,9 @@ class WebPushClient(Communicator): # type: ignore[misc]
|
|||||||
for sub in user["notification_tokens"]:
|
for sub in user["notification_tokens"]:
|
||||||
self.web_pushers[user["username"]].append(WebPusher(sub))
|
self.web_pushers[user["username"]].append(WebPusher(sub))
|
||||||
|
|
||||||
|
# notification config updater
|
||||||
|
self.config_subscriber = ConfigSubscriber("config/notifications")
|
||||||
|
|
||||||
def subscribe(self, receiver: Callable) -> None:
|
def subscribe(self, receiver: Callable) -> None:
|
||||||
"""Wrapper for allowing dispatcher to subscribe."""
|
"""Wrapper for allowing dispatcher to subscribe."""
|
||||||
pass
|
pass
|
||||||
@ -101,7 +105,11 @@ class WebPushClient(Communicator): # type: ignore[misc]
|
|||||||
|
|
||||||
def publish(self, topic: str, payload: Any, retain: bool = False) -> None:
|
def publish(self, topic: str, payload: Any, retain: bool = False) -> None:
|
||||||
"""Wrapper for publishing when client is in valid state."""
|
"""Wrapper for publishing when client is in valid state."""
|
||||||
## TODO update notification config
|
# check for updated notification config
|
||||||
|
_, updated_notif_config = self.config_subscriber.check_for_update()
|
||||||
|
|
||||||
|
if updated_notif_config:
|
||||||
|
self.config.notifications = updated_notif_config
|
||||||
|
|
||||||
if not self.config.notifications.enabled:
|
if not self.config.notifications.enabled:
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user