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

@@ -1571,14 +1571,14 @@
<!-- Telegram-asetukset -->
<div class="table-card" id="settings-telegram-card" style="padding:1.5rem;margin-top:1rem;display:none;">
<h3 style="color:#0f3460;margin-bottom:0.5rem;border-bottom:2px solid #f0f2f5;padding-bottom:0.5rem;">Telegram-hälytykset</h3>
<p style="color:#666;font-size:0.85rem;margin-bottom:1rem;">URGENT-prioriteetin tiketit lähettävät hälytyksen Telegram-bottiin.</p>
<p style="color:#666;font-size:0.85rem;margin-bottom:1rem;">URGENT-prioriteetin tiketit lähettävät hälytyksen Telegram-kanavalle. Chat ID on yrityskohtainen — eri yritykset voivat käyttää eri kanavia.</p>
<div class="form-grid" style="max-width:500px;">
<div class="form-group full-width">
<label>Bot Token</label>
<div class="form-group full-width" id="telegram-token-group">
<label>Bot Token <span style="color:#888;font-weight:normal;font-size:0.8rem;">(globaali, kaikille yrityksille sama)</span></label>
<input type="text" id="settings-telegram-token" placeholder="123456:ABC-DEF..." style="font-family:monospace;">
</div>
<div class="form-group full-width">
<label>Chat ID</label>
<label>Chat ID <span style="color:#888;font-weight:normal;font-size:0.8rem;">(yrityskohtainen kanava/ryhmä)</span></label>
<input type="text" id="settings-telegram-chat" placeholder="-1001234567890" style="font-family:monospace;">
</div>
<div class="form-group full-width" style="display:flex;gap:0.5rem;">