Skip to main content

Module notifications

Module notifications 

Source
Expand description

Per-operator notifications — a small rustio_notifications table + a public send helper for project code.

Schema:

CREATE TABLE rustio_notifications (
    id         BIGSERIAL    PRIMARY KEY,
    user_id    BIGINT       NOT NULL REFERENCES rustio_users(id) ON DELETE CASCADE,
    message    TEXT         NOT NULL,
    url        TEXT         NOT NULL DEFAULT '',
    read_at    TIMESTAMPTZ,
    created_at TIMESTAMPTZ  NOT NULL DEFAULT NOW()
);

Projects emit notifications via [rustio_admin::send_notification] — anywhere a Db is in scope. Every authenticated admin page renders a bell in the topbar with an unread-count badge; the operator clicks through to /admin/notifications, scans the list, and hits “Mark all read” to clear the badge.

v1 scope: per-row dismissal is not yet shipped — the page offers a single “mark every notification for this operator as read” action. Operators with high notification volume can filter by date in a future iteration.

Structs§

Notification
One stored notification. Surfaced by [list_for_user] for the admin UI.

Functions§

ensure_table
Ensure the rustio_notifications table + its unread-lookup index exist. Idempotent.
send
Persist one notification targeted at user_id. url may be empty when the message stands on its own (no click-through). Returns the new row’s id on success.