Add a test notice button to Site settings

Panel → Site settings → Notices → Send a test notice emails the
addresses in the box now and shows where it came from, or Google's
reason for refusing, so the Gmail setup can be checked without the
journal. Superadmins only (POST /api/admin/panel/test-notice).

The docs now say the sender must be a Workspace user: a group can't
be acted as through delegation, though it can receive notices.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-29 17:18:43 -05:00
parent c63478a72a
commit 8fd3a9b15b
5 changed files with 148 additions and 9 deletions

View file

@ -83,15 +83,26 @@ For the service account to send as a Workspace user:
controls → **Manage domain wide delegation** → Add new.
2. Client ID: the service account's Client ID from step 1.
OAuth scopes: `https://www.googleapis.com/auth/gmail.send`
3. `GOOGLE_MAIL_FROM` is the address it sends as. It must be a real
user or group-owned mailbox in the Workspace (not an alias); a
dedicated `web@` account keeps the sent mail out of anyone's inbox.
3. `GOOGLE_MAIL_FROM` is the address it sends as. It must be a
**user** in the Workspace, one that signs in and has Gmail: not a
group (eg. `webb-admin@`, even mail-enabled), not an alias. The
service account acts as that user, and a group can't be acted as;
Google answers `Client is unauthorized to retrieve access tokens`.
A dedicated user such as `web@` keeps the sent copies out of anyone's
own mailbox. A group is fine as a **recipient** (below): each member
gets the notice.
Then in the admin, Panel → Site settings → Notices → "Email new
requests to": one or more addresses, separated by commas. Each new
content request and data request sends one plain-text email with a link
to the queue; replying goes to the person who sent the request.
**Send a test notice**, under that box, emails whatever addresses are in
it (saved or not) straight away and shows the result on the page:
where it was sent from, or Google's reason for refusing. A new
delegation can take a while to start working, so retry it after a few
minutes before changing anything.
## 4. The service and nginx
```sh
@ -122,13 +133,19 @@ location = /api/requests {
## Checking it
- Mail: Panel → Site settings → Notices → **Send a test notice**.
- Send a request with a small file at `/request`. The journal shows
`feedback #N (content: new blog, 1 files)`, and with mail on,
`feedback #N: notice sent to 1`.
- The file is in the shared drive's Requests folder (made on the first upload), and downloads from Forms → Content
requests.
- `token refused: unauthorized_client` on mail means the delegation
(step 3) is missing or has the wrong Client ID or scope. `404 File not
- `Client is unauthorized to retrieve access tokens` (or
`unauthorized_client`) on mail: `GOOGLE_MAIL_FROM` is a group or alias
rather than a user, or the delegation (step 3) is missing, has the
wrong Client ID (the service account's numeric Unique ID), or a scope
other than exactly `https://www.googleapis.com/auth/gmail.send`, or
is too new to have taken effect. `404 File not
found` on upload means `GOOGLE_SHARED_DRIVE` isn't the bare id (a
whole URL, say) or the service account isn't a member of the shared
drive.