Make Telegram chat_id per-company, bot token stays global

Each company can now have its own Telegram channel/group for alerts.
- Bot token: global (superadmin only, shared across companies)
- Chat ID: per-company (stored in integrations table config)
- sendTelegramAlert reads chat_id from company integration
- Test message shows company name
- Non-superadmin users can't see/edit bot token

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 19:05:57 +02:00
parent bbfff2f8b5
commit 20a2b78782
3 changed files with 40 additions and 14 deletions

View File

@@ -2738,6 +2738,9 @@ async function loadSettings() {
// Telegram-asetukset
document.getElementById('settings-telegram-token').value = config.telegram_bot_token || '';
document.getElementById('settings-telegram-chat').value = config.telegram_chat_id || '';
// Bot Token vain superadminille
const tokenGroup = document.getElementById('telegram-token-group');
if (tokenGroup) tokenGroup.style.display = currentUser?.role === 'superadmin' ? '' : 'none';
} catch (e) { console.error(e); }
// Lataa saatavuuskyselyt