corvix.actions ============== .. py:module:: corvix.actions .. autoapi-nested-parse:: Action execution for matched rules. Classes ------- .. autoapisummary:: corvix.actions.MarkReadGateway corvix.actions.DismissGateway corvix.actions.ActionExecutionResult corvix.actions.ActionExecutionContext corvix.actions._ActionHandler corvix.actions._MarkReadHandler corvix.actions._DismissHandler Functions --------- .. autoapisummary:: corvix.actions.execute_actions Module Contents --------------- .. py:class:: MarkReadGateway Bases: :py:obj:`Protocol` Gateway interface for marking notification threads as read. .. py:method:: mark_thread_read(thread_id: str) -> None Mark a thread as read. .. py:class:: DismissGateway Bases: :py:obj:`Protocol` Gateway interface for dismissing (deleting) notification threads. .. py:method:: dismiss_thread(thread_id: str) -> None Dismiss a thread from the inbox permanently. .. py:class:: ActionExecutionResult Summary of actions taken on one notification. .. py:attribute:: actions_taken :type: list[str] :value: [] .. py:attribute:: errors :type: list[str] :value: [] .. py:class:: ActionExecutionContext Bundles all execution dependencies for :func:`execute_actions`. Attributes: gateway: Must implement :class:`MarkReadGateway`. apply_actions: If ``False`` actions are recorded as dry-run only. dismiss_gateway: Must implement :class:`DismissGateway`; required for dismiss actions. record: The associated :class:`~corvix.domain.NotificationRecord` used for dismiss state tracking. .. py:attribute:: gateway :type: MarkReadGateway .. py:attribute:: apply_actions :type: bool :value: False .. py:attribute:: dismiss_gateway :type: DismissGateway | None :value: None .. py:attribute:: record :type: corvix.domain.NotificationRecord | None :value: None .. py:class:: _ActionHandler Bases: :py:obj:`Protocol` Strategy interface for a single action type. .. py:method:: execute(notification: corvix.domain.Notification, result: ActionExecutionResult) -> None Execute the action, mutating *result* in place. .. py:class:: _MarkReadHandler(gateway: MarkReadGateway, apply_actions: bool) Handles the ``mark_read`` action. .. py:attribute:: _gateway .. py:attribute:: _apply_actions .. py:method:: execute(notification: corvix.domain.Notification, result: ActionExecutionResult) -> None .. py:class:: _DismissHandler(gateway: DismissGateway | None, apply_actions: bool, record: corvix.domain.NotificationRecord | None) Handles the ``dismiss`` action. .. py:attribute:: _gateway .. py:attribute:: _apply_actions .. py:attribute:: _record .. py:method:: execute(notification: corvix.domain.Notification, result: ActionExecutionResult) -> None .. py:function:: execute_actions(notification: corvix.domain.Notification, actions: list[corvix.config.RuleAction], context: ActionExecutionContext) -> ActionExecutionResult Execute configured actions against a notification. Args: notification: The notification to act on. actions: The list of rule actions to execute. context: Execution context carrying gateways and flags.