Add instance settings and mail delivery through PocketBase

Superadmins can now change signup rules (on/off and the domain allow-list)
and branding at runtime; the environment variables only seed the defaults.
Mail and S3 storage settings pass through to PocketBase's own settings, and
docwell-server sends its own emails through a PocketBase hook so there is a
single SMTP configuration. The boot hook no longer wipes SMTP settings that
were not set from the environment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tajniak81andClaude Opus 5.5 committed 2026-10-31 16:22:53 +01:00
1 parent ba394b8fac
commit e33a99241e
21 files changed
+1714 -25

No files matched your search

+136
View File
@@ -850,6 +850,81 @@ paths:
schema: { $ref: "#/components/schemas/Page" }
"403": { $ref: "#/components/responses/Error" }
"404": { $ref: "#/components/responses/Error" }
/api/v1/settings/public:
get:
operationId: getPublicSettings
tags: [settings]
summary: Branding and signup availability, for signed-out pages
responses:
"200":
description: OK
content:
application/json:
schema: { $ref: "#/components/schemas/PublicSettings" }
/api/v1/admin/settings:
get:
operationId: getInstanceSettings
tags: [settings]
summary: Every instance setting (superadmin)
security: [{ bearer: [] }]
responses:
"200":
description: OK
content:
application/json:
schema: { $ref: "#/components/schemas/InstanceSettings" }
"403": { $ref: "#/components/responses/Error" }
patch:
operationId: updateInstanceSettings
tags: [settings]
summary: Change the sections that are present (superadmin)
description: >-
Mail and storage settings are PocketBase's own. Passwords and secrets are write-only:
leave them out to keep the stored value. Environment variables such as
DOCWELL_SMTP_HOST are applied again when docwell-db starts.
security: [{ bearer: [] }]
requestBody:
required: true
content:
application/json:
schema: { $ref: "#/components/schemas/InstanceSettingsUpdate" }
responses:
"200":
description: Saved
content:
application/json:
schema: { $ref: "#/components/schemas/InstanceSettings" }
"400": { $ref: "#/components/responses/Error" }
"403": { $ref: "#/components/responses/Error" }
/api/v1/admin/settings/test-email:
post:
operationId: sendTestEmail
tags: [settings]
summary: Send a test email with the saved mail settings (superadmin)
security: [{ bearer: [] }]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [to]
properties:
to: { type: string, format: email }
responses:
"204": { description: Sent }
"400": { $ref: "#/components/responses/Error" }
"403": { $ref: "#/components/responses/Error" }
/api/v1/admin/settings/test-storage:
post:
operationId: testStorage
tags: [settings]
summary: Check that the configured S3 bucket is reachable (superadmin)
security: [{ bearer: [] }]
responses:
"204": { description: Reachable }
"400": { $ref: "#/components/responses/Error" }
"403": { $ref: "#/components/responses/Error" }
components:
securitySchemes:
bearer:
@@ -1110,3 +1185,64 @@ components:
properties:
name: { type: string }
version: { type: string }
PublicSettings:
type: object
required: [appName, accentColor, logo, signup]
properties:
appName: { type: string }
accentColor: { type: string, description: "#rrggbb, or empty for the default" }
logo: { type: string, description: A data URL, or empty for the Docwell logo }
signup: { type: boolean, description: Self-service signup is open }
SignupSettings:
type: object
required: [enabled, domains]
properties:
enabled: { type: boolean }
domains: { type: array, items: { type: string }, description: Allowed email domains; empty allows all }
BrandingSettings:
type: object
required: [appName, accentColor, logo]
properties:
appName: { type: string, maxLength: 60 }
accentColor: { type: string }
logo: { type: string, description: "data:image/(png|jpeg|webp|svg+xml);base64,..., at most 256 KB" }
SmtpSettings:
type: object
required: [enabled, host, port, username, passwordSet, tls, senderName, senderAddress]
properties:
enabled: { type: boolean }
host: { type: string }
port: { type: integer }
username: { type: string }
password: { type: string, writeOnly: true, description: Leave out to keep the stored password }
passwordSet: { type: boolean, readOnly: true }
tls: { type: boolean }
senderName: { type: string }
senderAddress: { type: string }
StorageSettings:
type: object
required: [s3, bucket, region, endpoint, accessKey, secretSet, forcePathStyle]
properties:
s3: { type: boolean, description: false stores files on docwell-db's disk }
bucket: { type: string }
region: { type: string }
endpoint: { type: string }
accessKey: { type: string }
secret: { type: string, writeOnly: true, description: Leave out to keep the stored secret }
secretSet: { type: boolean, readOnly: true }
forcePathStyle: { type: boolean }
InstanceSettings:
type: object
required: [signup, branding, smtp, storage]
properties:
signup: { $ref: "#/components/schemas/SignupSettings" }
branding: { $ref: "#/components/schemas/BrandingSettings" }
smtp: { $ref: "#/components/schemas/SmtpSettings" }
storage: { $ref: "#/components/schemas/StorageSettings" }
InstanceSettingsUpdate:
type: object
properties:
signup: { $ref: "#/components/schemas/SignupSettings" }
branding: { $ref: "#/components/schemas/BrandingSettings" }
smtp: { $ref: "#/components/schemas/SmtpSettings" }
storage: { $ref: "#/components/schemas/StorageSettings" }