Skip to content

Web-based config editor setup#54

Merged
Archasion merged 3 commits into
mainfrom
feat/config-editor-phase-0
May 9, 2026
Merged

Web-based config editor setup#54
Archasion merged 3 commits into
mainfrom
feat/config-editor-phase-0

Conversation

@Archasion
Copy link
Copy Markdown
Member

No description provided.

Archasion added 3 commits May 9, 2026 16:42
Two additions to the config schema, both in service of an upcoming
sibling `azalea-editor` web service. Both are optional / inert from
the bot's perspective — the bot does not consume either.

- New `Permission.ManageGuildConfig = "manage_guild_config"`. The
  editor will gate config-edit access by checking this permission
  via the same role-based pattern the bot already uses
  (`GuildConfig.hasPermission`).
- New optional `preview` block on the global config:

      preview:
        test_channel_id: <snowflake>
        test_webhook_url: https://discord.com/api/webhooks/<id>/<token>

  Both fields are optional and validated independently. Webhook URL
  validation matches the standard `discord.com` / `discordapp.com`
  shape so typos surface at parse time rather than at the moment a
  preview is requested. The editor reads these fields to power its
  "Test in Discord" button; preview is only enabled when both are
  set.
…tion

Add a tiny localhost-only HTTP listener (Bun.serve, no new deps) so
the sibling `azalea-editor` service can detect a successful pm2
reload. The editor uses this signal to decide whether a config save
succeeded or needs to be rolled back.

- `src/utils/health.ts`: starts the listener at module load and
  returns `{ markReady, startedAt }`. `startedAt` is the ISO
  timestamp captured when the process boots; the editor compares
  it against the value seen pre-reload to confirm it's looking at
  the new process. PM2's own `restart_time` and `online` status
  are insufficient — they flip before ClientReady fires.
- `src/index.ts`: imports and starts the server before any other
  startup work so the editor can reach it the moment the new
  process spawns.
- `src/events/Ready.ts`: calls `health.markReady()` only after
  every cron job (scheduled messages, review reminders, report
  removal) is mounted. A 200 with `ready: true` therefore means
  the bot is fully operational, not merely logged in.
- `.env.example`: documents the optional `HEALTH_HOST` /
  `HEALTH_PORT` overrides. Defaults to 127.0.0.1:7475; the
  endpoint must never be exposed beyond loopback.
- `tests/health.test.ts`: covers the ready transition,
  startedAt persistence, and 404 for unknown paths.
The sibling editor's "Send to test channel" feature was removed, so
the only consumer of `globalConfigSchema.preview` is gone. Drop the
field, its `webhookUrlSchema` regex, and the corresponding YAML
example in the README. Add `configs/.backups` to .gitignore so the
editor's runtime config backups never accidentally land in commits,
and tag VIRUSTOTAL_API_KEY as optional in .env.example for parity
with the other secondary integrations.

`Permission.ManageGuildConfig` stays — the editor still uses it as
the per-guild access gate.
@Archasion Archasion merged commit 9b70a48 into main May 9, 2026
3 checks passed
@Archasion Archasion deleted the feat/config-editor-phase-0 branch May 10, 2026 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant