mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-02-16 12:53:12 -05:00
Feature/group based notifications (#918)
* fix group page * setup group notification for backend * update type generators * script to auto-generate schema exports * setup frontend CRUD interface * remove old notifications UI * drop old events api * add test functionality * update naming for fields * add event dispatcher functionality * bump to python 3.10 * bump python version * purge old event code * use-async apprise * set mealie logo as image * unify styles for buttons rows * add links to banners
This commit is contained in:
29
mealie/services/event_bus_service/publisher.py
Normal file
29
mealie/services/event_bus_service/publisher.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from typing import Protocol
|
||||
|
||||
import apprise
|
||||
|
||||
from mealie.services.event_bus_service.event_bus_service import EventBusMessage
|
||||
|
||||
|
||||
class PublisherLike(Protocol):
|
||||
def publish(self, event: EventBusMessage, notification_urls: list[str]):
|
||||
...
|
||||
|
||||
|
||||
class ApprisePublisher:
|
||||
def __init__(self, hard_fail=False) -> None:
|
||||
asset = apprise.AppriseAsset(
|
||||
async_mode=True,
|
||||
image_url_mask="https://raw.githubusercontent.com/hay-kot/mealie/dev/frontend/public/img/icons/android-chrome-maskable-512x512.png",
|
||||
)
|
||||
self.apprise = apprise.Apprise(asset=asset)
|
||||
self.hard_fail = hard_fail
|
||||
|
||||
def publish(self, event: EventBusMessage, notification_urls: list[str]):
|
||||
for dest in notification_urls:
|
||||
status = self.apprise.add(dest)
|
||||
|
||||
if not status and self.hard_fail:
|
||||
raise Exception("Apprise URL Add Failed")
|
||||
|
||||
self.apprise.notify(title=event.title, body=event.body)
|
||||
Reference in New Issue
Block a user