15 Commits
Author SHA1 Message Date
NanamiAdminandClaude Code cb2df5076d refactor(config): publish config singletons through atomic pointers
The three configuration singletons (C_globalConfig, C_botUserConfig,
C_botNodeConfig) were plain variables: LoadGlobalConfig and friends assigned
them from the goroutine handling a settings update, while bot pipes, the node
tracker and the HTTP handlers read them from their own goroutines. That is an
unsynchronized read of a concurrently written variable — a data race the race
detector reports, and one that already existed before any hot-reload work
because /api/webhook/add reloads the configuration while the bots run.

Replace them with atomic.Pointer values behind Current(), BotUsers() and
BotNodes(). Each reload builds a fresh value and publishes it atomically, so a
reader either sees the previous configuration or the new one, never a partial
one. Callers read through the accessor on every use instead of caching it.

Two spots that read several fields of one guard now snapshot once per call, so
a reload cannot split a combined check mid-flight:
- qq_napcat.handleNapcatEvent, which evaluates the debug guards per event
- the komari task-echo guard, now behind taskEchoEnabled()

The NapCat HTTP methods keep logging on showNapcatAction alone (without
requiring debugMode), matching their existing behaviour; that inconsistency
with the WebSocket path is preserved, not introduced, and is called out in
actionLogEnabled.

Also adds TestConcurrentReloadAndRead, which drives every accessor from four
reader goroutines while two writers reload the configuration, and sanitises the
member IDs used as test fixtures in config/settings_test.go.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-09-28 22:47:37 +08:00
NanamiAdmin 057d7d584d feat: add incoming webhook API support with configurable endpoints
- Implemented the incoming webhook API to handle alerts from external applications.
- Added configuration options for webhook listening address, port, and endpoints in config.go.
- Created WebhookReceiverConfig and WebhookEndpointConfig structures to manage webhook settings.
- Developed WebhookHandler to process incoming requests, validate tokens, and deliver alerts to specified channels.
- Enhanced existing controller interfaces to support alert delivery.
- Updated message rendering to respect Markdown settings for different channels.
- Added tests for webhook functionality and ensured proper error handling.
2026-09-24 11:21:38 +08:00
NanamiAdmin ec1cf20347 feat(config): implement loading and saving of bot node configuration with default notification settings 2026-09-06 14:00:45 +08:00
NanamiAdmin 6a0c2d1fc4 feat(controller): add per-node notify switch controller 2026-09-06 10:48:38 +08:00
NanamiAdmin 5bc85effa7 feat(komari): add bot_node_config.json to restore single node configurarion 2026-09-06 10:33:58 +08:00
NanamiAdmin 6c819f8c52 feat(controller): enhance message handling and user options for automatic notifications 2026-09-03 11:57:20 +08:00
NanamiAdmin bf4cdf0d88 chore(config): move admins && trustedGroups to a new config bot_user_config.json.
feat(config): add load bot_user_config endpoint
style(config): rename `LoadConfig` to `LoadGlobalConfig`.
2026-09-02 21:19:50 +08:00
NanamiAdmin f2cc16177c feat(controller): add source for command handling.
feat(telegram): switch message type to markdown
feat(controller): add welcome message for telegram bot.
2026-08-13 17:07:55 +08:00
NanamiAdmin 56cc3485a7 feat(netproxy): add network proxy module to provide unified network proxy connection.
feat(internal/controller): make email, ntft, webhook, qq_napcat able to use network proxy.
2026-08-12 22:53:23 +08:00
NanamiAdmin 105fa47811 feat(debug): make komari task echo log to debug level and selectable
feat(internal/controller/qq_napcat): add trigger log display and detailed to chatID and senderID
2026-08-12 22:29:57 +08:00
NanamiAdmin 8cd7cfd6e7 feat(controller): add help command with message template for bot commands 2026-08-07 22:39:57 +08:00
NanamiAdmin 56ed32ac0c feat(controller): add init message for bot pipes
chore: move softwareInfo from main package to a individual global package
2026-08-07 22:13:15 +08:00
NanamiAdmin 30ed0bd9ec chore(internal/controller): split command processor from pipes as an individual module 2026-08-06 17:53:53 +08:00
NanamiAdmin 1d09765a4a chore(qq_napcat): rewrite all napcat_bridge logic into this project to replace adapt into napcat_bridge 2026-08-05 17:07:29 +08:00
NanamiAdmin 19b69acc29 feat: finish project basic structure and core functions 2026-08-03 22:15:53 +08:00