s365b.notify.delivery ===================== .. py:module:: s365b.notify.delivery .. autoapi-nested-parse:: Delivering recorded events by email. Attributes ---------- .. autoapisummary:: s365b.notify.delivery.log s365b.notify.delivery.RETRY_DELAYS Functions --------- .. autoapisummary:: s365b.notify.delivery.build_notifier s365b.notify.delivery.send_with_fallback s365b.notify.delivery.deliver_pending s365b.notify.delivery.send_test Module Contents --------------- .. py:data:: log .. py:data:: RETRY_DELAYS .. py:function:: build_notifier(services: s365b.core.services.Services, s: sqlalchemy.ext.asyncio.AsyncSession, method: str, cfg: s365b.notify.settings.NotificationSettings, stack: contextlib.AsyncExitStack) -> s365b.notify.senders.Notifier :async: Create the notifier for a method. :param services: Process services (tests replace ``notifier_factory``). :param s: Open session. :param method: ``graph`` or ``smtp``. :param cfg: Notification settings. :param stack: Closes the Graph client when delivery is done. :returns: The notifier. :raises SendError: If the method is not set up. .. py:function:: send_with_fallback(services: s365b.core.services.Services, s: sqlalchemy.ext.asyncio.AsyncSession, cfg: s365b.notify.settings.NotificationSettings, message: s365b.notify.message.Message, stack: contextlib.AsyncExitStack) -> str | None :async: Send through the primary method, then the fallback. :param services: Process services. :param s: Open session. :param cfg: Notification settings. :param message: The message. :param stack: Owns Graph clients. :returns: A note if the primary failed but the fallback worked, else ``None``. :raises SendError: If every method failed (message lists each error). .. py:function:: deliver_pending(services: s365b.core.services.Services, *, now: datetime.datetime | None = None, limit: int = 50) -> dict[str, int] :async: Deliver events that are due. Each event is sent, skipped (email off, or below the minimum severity), throttled (the same alert was sent recently), or retried later; after the last retry it is marked failed. Its state is visible in the UI. :param services: Process services. :param now: Current time (tests). :param limit: Most events handled per call. :returns: Count of events per outcome. .. py:function:: send_test(services: s365b.core.services.Services, cfg: s365b.notify.settings.NotificationSettings, method: str) -> None :async: Send a test email with one method (no fallback). :param services: Process services. :param cfg: Settings to test (may be unsaved edits). :param method: ``graph`` or ``smtp``. :raises SendError: With the reason it failed.