Skip to content
Corex

NotificationService

Corex\Notifications\NotificationService · interface · Core layer

The boundary producers and UI program against. It owns publishing (with dedup + loop-safe channel delivery) and actor-scoped reading, delegating storage to {@see NotificationRepository}. Modules publish through this contract; the Center never reaches into a module’s private tables (spec 072). Every …ForCurrentActor method resolves “the current actor” from WordPress and re-checks visibility through the repository, so a caller can never read or mutate a notification it may not see — the read/own-action tier of the REST gate rests on that (FR-002/FR-003).

publish(Notification $notification): Notification

Section titled “publish(Notification $notification): Notification”

Publish a notification (or record another occurrence of an existing condition).

resolve(string $dedupKey, string $reason): int

Section titled “resolve(string $dedupKey, string $reason): int”

Resolve a condition-based notification by its dedup key when the condition ends.

Say an open condition in the words of the request that is evaluating it, without recording another occurrence (spec 118): a readiness blocker is raised once, and still reads in the language of the person who opens the screen that evaluates it.

forCurrentActor(NotificationQuery $query): array

Section titled “forCurrentActor(NotificationQuery $query): array”

The current actor’s bounded, visibility-filtered notifications.

The current actor’s unread count (bounded aggregate; safe to cache briefly).

findForCurrentActor(int $notificationId): ?array

Section titled “findForCurrentActor(int $notificationId): ?array”

One notification presented for the current actor, or null if absent or not theirs to see.

markReadForCurrentActor(int $notificationId): bool

Section titled “markReadForCurrentActor(int $notificationId): bool”

Per-user state mutations for the current actor. Each returns false when it is not theirs.

markUnreadForCurrentActor(int $notificationId): bool

Section titled “markUnreadForCurrentActor(int $notificationId): bool”

dismissForCurrentActor(int $notificationId): bool

Section titled “dismissForCurrentActor(int $notificationId): bool”

snoozeForCurrentActor(int $notificationId, DateTimeImmutable $until): bool

Section titled “snoozeForCurrentActor(int $notificationId, DateTimeImmutable $until): bool”

Mark every notification the current actor can see as read; returns the number affected.

resolveById(int $notificationId, string $reason): bool

Section titled “resolveById(int $notificationId, string $reason): bool”

Resolve the condition a notification belongs to (manage tier). False if the id is unknown.