fix: plugin bot user + await plugin detection before session scan

- Add EnsureBotUser on plugin activate (fixes 'Unable to find user' error)
- Accept bot_user_id in create session request
- Await plugin health check before starting session monitor
  (prevents race where sessions detect before plugin flag is set)
- Plugin now creates custom_livestatus posts with proper bot user
This commit is contained in:
sol
2026-03-07 22:25:59 +00:00
parent 42755e73ad
commit 7aebebf193
4 changed files with 56 additions and 6 deletions

View File

@@ -171,13 +171,17 @@ async function startDaemon() {
logger: logger.child({ module: 'plugin-client' }),
});
// Initial plugin detection
pluginClient.isHealthy().then(function (healthy) {
// Initial plugin detection (awaited before monitor starts — see below)
try {
var healthy = await pluginClient.isHealthy();
usePlugin = healthy;
logger.info({ usePlugin, url: config.plugin.url }, healthy
? 'Plugin detected — using WebSocket rendering mode'
: 'Plugin not available — using REST API fallback');
});
} catch (_detectErr) {
usePlugin = false;
logger.warn('Plugin detection failed — using REST API fallback');
}
// Periodic re-detection
setInterval(function () {