You're reading docs for Nextly Alpha. APIs may change between releases.

Notices

Notices

Each admin user's own Inbox of notices — what happened to their work that they should know about.

A notice tells one person something: what someone did that involves them, such as a review assigned to them, or a problem on the site that needs fixing, such as a release that stopped. Every admin user has their own list, not only super-admins, and nobody sees anyone else's.

What a notice is

ForExactly one person, who is the only one who can see it or mark it read
AboutOne thing, such as a release, kept as a snapshot so the notice still reads correctly after that thing is deleted
OnceA notice is stored once per occurrence: a release that stops twice gives two notices, and the same stop seen twice gives one
ReadEach notice records when its person read it (readAt), and is unread while that is empty. Marking it unread clears the time; reading it again records the new one
KindEach notice has a kind, which says what it is for: what a person did (For you) or a site problem (Alerts)

The Inbox

Every admin user has an Inbox button, a tray icon at the foot of the left rail, showing how many of their notices are unread ("Inbox, 3 unread" to a screen reader). It opens a list with two tabs:

  • For you: what people did that involves you, such as a review assigned to you. Its count is how many are unread.
  • Alerts: what on the site needs fixing, such as a release of yours that stopped or missed its time. Its count is how many alerts are still open, read or not.

The Inbox opens on Alerts while Alerts has unread notices, and on For you otherwise.

A notice is read when you open it, by clicking it or pressing Enter on it, which also takes you to what it is about. Showing a notice in the Inbox never marks it read. Mark all read marks every unread notice in the tab shown, including those further down than the Inbox shows, and none in the other tab. A read notice's menu has Mark as unread.

Alerts stay until they are fixed

An alert is not over when you read it: it stays in Alerts, marked "stays until fixed", until the part of the site it came from says the problem is over. Then it is fixed for everyone who received it, and it leaves the Inbox's Alerts tab. A release alert, for example, is fixed when the release is scheduled again, cancelled or published, and an alert whose subject was deleted is fixed too. A fixed alert no longer counts toward the Inbox button's number, even if you never read it.

While an alert of a critical kind is open, the Inbox button carries a red mark and says so to screen readers ("Inbox, 1 critical alert"), even when nothing is unread. A stopped release and a release that missed its time are critical.

Who a release alert reaches

When a release stops, or misses its time, its creator and every person who may publish releases get an alert, each their own, and its email. The creator's alert is there at once and their email goes out on the site's next run of its jobs; the people who may publish releases get their alerts on that next run and their emails on the run after. Someone who may only read releases gets none, unless they created the release. Each person is told once per occurrence: the same stop seen twice tells nobody again, and a release stopped again after it was rescheduled tells everyone again. A person given the publish permission while a release is still overdue is told on the next run of the site's jobs.

The alert is fixed by the change that sorts the release, for everyone at once:

AlertFixed when the release is
Release stoppedscheduled again, cancelled or run
Release missed its timerun, rescheduled so it is no longer overdue, cancelled, or stopped

A release that runs late tells everyone who hadn't yet been told that it missed its time, with a "ran late" email; since it has run, that alert is fixed straight away and doesn't stay in Alerts. Whether a release stopped or is overdue is decided by the same rule as the Releases page's and the dashboard's Needs attention, so an alert and Needs attention agree. One exception: a release moved back to the exact time it already missed is listed in Needs attention again, but its fixed "missed its time" alert doesn't reopen. A release that misses any other time gets a new alert as usual.

Done

You can file a notice away as Done, so it leaves both tabs and every count. An alert that is still open can't be marked Done: it stays until it is fixed. A Done notice can be moved back.

Repeats and groups

The same notice recorded again changes nothing if it says the same, so a repeat never makes a read notice unread. If it says something new (a key that expires "in 3 days" where it said "in 14"), it replaces the old one: the new text, at the top of the list, unread again.

Some kinds of notice group their items, such as failed deliveries to one address. Your unread or open items of one group show as one row, marked "grouped", with their count and the newest one's time, and they count once. Opening the row reads them all.

Nobody is told about their own action: a notice is never recorded for the person whose act it reports.

Whether a notice is read is kept on the server, not in the browser, so the count is the same in every browser and on every device you sign in on. The count is asked for again when you come back to the admin's browser tab, and every minute while it is open.

A plugin that hides the admin's notifications control, through hide or hideDefaults in its contributes.admin.header, hides the Inbox button.

Notices are kept for as long as the activity log keeps its records (90 days by default, set by audit.retention), and a person's notices are deleted with their account.

Reading notices

Over REST, for the signed-in person. The person is always the one signed in: no request can name someone else. API keys are refused, since a notice belongs to a person's own inbox.

RequestAnswer
GET /api/notices?tab=alerts&open=true&page=1&limit=20The standard list envelope, most recently written first. limit is at most 100
GET /api/notices/count{ "total": 3, "forYou": 2, "alerts": 1, "critical": 1 }
POST /api/notices/read with { "ids": ["…"] }, { "all": true } or { "all": true, "tab": "alerts" }How many were marked. Ids that are not yours are ignored
POST /api/notices/unread with { "ids": ["…"] }How many were made unread again. Ids that are not yours are ignored
POST /api/notices/done with { "ids": ["…"] }How many were marked Done. Refused if one of them is an alert still open
POST /api/notices/undone with { "ids": ["…"] }How many were moved back from Done

tab is for-you or alerts; leave it out for both. unread=true lists only unread notices, open=true only alerts still open, and done=true the Done notices instead of the tabs. The count's total is your unread notices in both tabs and forYou the unread ones in For you; alerts is the open alerts and critical the open alerts of a critical kind. A group counts once in each.

tab, open, done, the count's fields, /unread, /done and /undone, and the fields below other than title, body, kind, subject, createdAt and readAt are experimental: they may change until the Inbox is complete.

Each notice has its title and optional body, its kind, and its subject: its type, id, a link into the admin, and gone: true once the subject no longer exists. It also has its intent (activity for For you, operational for an alert), critical, createdAt and updatedAt (when it was last replaced), readAt, resolvedAt (when an alert was fixed), doneAt, and group ({ key, count } for a row that stands for a group, otherwise null; key is an opaque identifier of the group, the same for every row of it).

From server code, the Direct API does the same for a person you name:

import { getNextly } from "nextly";

import config from "../../nextly.config";

const nextly = await getNextly({ config });
const userId = "the person's user id";

const { items, meta } = await nextly.notices.find({ userId, unread: true });
const unread = await nextly.notices.count({ userId, unread: true });
await nextly.notices.markRead({ userId, all: true });

// Experimental: one tab at a time, the Inbox's counts, unread again, and Done.
const openAlerts = await nextly.notices.find({
  userId,
  tab: "alerts",
  open: true,
});
const { total, forYou, alerts, critical } = await nextly.notices.counts({
  userId,
});
await nextly.notices.markRead({ userId, all: true, tab: "for-you" });
await nextly.notices.markUnread({ userId, ids: [items[0].id] });
// Done takes a For you item or a fixed alert: an open alert stays until it is fixed.
const { items: forYouItems } = await nextly.notices.find({
  userId,
  tab: "for-you",
});
await nextly.notices.markDone({ userId, ids: [forYouItems[0].id] });
await nextly.notices.markUndone({ userId, ids: [forYouItems[0].id] });

Before nextly migrate

The notices table is created, and brought up to date for the Inbox, by nextly migrate. Until it has run, lists are empty and notices are not recorded, and the server logs one warning naming the table and the command. Nothing else stops working: a release still stops or moves on as it would.

On a site that already had notices, nextly migrate adds the Inbox's columns and carries them over: release notices become alerts (each is fixed the first time it is read if its release has been sorted since), and every other notice stays in For you, read or unread as it was.