feat(settings): добавить Bot API URL и ячейку ошибок уведомлений
Docker / build (push) Failing after 26s
Docker / build (push) Failing after 26s
Монитор больше не ставит «Внимание» по скрытому счётчику. Telegram можно слать через локальный telegram-bot-api. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -30,4 +30,16 @@ describe('settingsRepository', () => {
|
||||
})
|
||||
expect(settingsRepository.getRow('settings-main')?.telegramBotToken).toBe('new-token')
|
||||
})
|
||||
|
||||
it('defaults telegramApiUrl to cloud origin and persists a custom URL', () => {
|
||||
const created = settingsRepository.upsert('settings-main', {
|
||||
telegramChatId: '-100',
|
||||
})
|
||||
expect(created.telegramApiUrl).toBe('https://api.telegram.org')
|
||||
|
||||
const updated = settingsRepository.upsert('settings-main', {
|
||||
telegramApiUrl: 'http://127.0.0.1:8081/',
|
||||
})
|
||||
expect(updated.telegramApiUrl).toBe('http://127.0.0.1:8081')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
appSwitcherConfigSchema,
|
||||
type AppSwitcherConfig,
|
||||
} from '@cfdm/shared/contracts/app-switcher'
|
||||
import { normalizeTelegramApiUrl } from '@cfdm/shared/contracts/settings'
|
||||
import { getDb, schema } from '../index.js'
|
||||
import {
|
||||
getCurrentSpaceId,
|
||||
@@ -111,6 +112,7 @@ function toDto(row: Row | undefined): SettingsDto | undefined {
|
||||
webhookEnabled: Boolean(row.webhookEnabled),
|
||||
integrationEnabled: Boolean(row.integrationEnabled),
|
||||
showQuickActions: row.showQuickActions == null ? true : Boolean(row.showQuickActions),
|
||||
telegramApiUrl: normalizeTelegramApiUrl(row.telegramApiUrl),
|
||||
notifyIntervalMinutes: Number(row.notifyIntervalMinutes) || 60,
|
||||
uptimeCheckIntervalMinutes: Number(row.uptimeCheckIntervalMinutes) || 5,
|
||||
customFields: Array.isArray(customFields) ? customFields : [],
|
||||
@@ -135,6 +137,7 @@ interface SettingsInput {
|
||||
syncTariffsIntervalMinutes?: number
|
||||
telegramBotToken?: string
|
||||
telegramChatId?: string
|
||||
telegramApiUrl?: string
|
||||
telegramMessageThreadId?: string
|
||||
notifyPaymentExpiryEnabled?: boolean
|
||||
notifyNewTariffsEnabled?: boolean
|
||||
@@ -179,6 +182,10 @@ function buildValues(id: string, spaceId: string, existing: Row | undefined, r:
|
||||
: existing?.telegramBotToken ?? '',
|
||||
telegramChatId:
|
||||
r.telegramChatId !== undefined ? r.telegramChatId || '' : existing?.telegramChatId ?? '',
|
||||
telegramApiUrl:
|
||||
r.telegramApiUrl !== undefined
|
||||
? normalizeTelegramApiUrl(r.telegramApiUrl)
|
||||
: normalizeTelegramApiUrl(existing?.telegramApiUrl),
|
||||
telegramMessageThreadId:
|
||||
r.telegramMessageThreadId !== undefined
|
||||
? r.telegramMessageThreadId || ''
|
||||
|
||||
@@ -146,6 +146,7 @@ const CORE_TABLE_MIGRATIONS: string[] = [
|
||||
customFields TEXT,
|
||||
telegramBotToken TEXT,
|
||||
telegramChatId TEXT,
|
||||
telegramApiUrl TEXT,
|
||||
notifyPaymentExpiryEnabled INTEGER,
|
||||
notifyNewTariffsEnabled INTEGER,
|
||||
telegramMessageThreadId TEXT,
|
||||
@@ -302,6 +303,7 @@ const COLUMN_MIGRATIONS: string[] = [
|
||||
`ALTER TABLE settings ADD COLUMN showQuickActions INTEGER`,
|
||||
`ALTER TABLE settings ADD COLUMN telegramBotToken TEXT`,
|
||||
`ALTER TABLE settings ADD COLUMN telegramChatId TEXT`,
|
||||
`ALTER TABLE settings ADD COLUMN telegramApiUrl TEXT`,
|
||||
`ALTER TABLE settings ADD COLUMN notifyPaymentExpiryEnabled INTEGER`,
|
||||
`ALTER TABLE settings ADD COLUMN notifyNewTariffsEnabled INTEGER`,
|
||||
`ALTER TABLE settings ADD COLUMN telegramMessageThreadId TEXT`,
|
||||
|
||||
@@ -194,6 +194,7 @@ export const settings = sqliteTable('settings', {
|
||||
customFields: text('customFields'),
|
||||
telegramBotToken: text('telegramBotToken'),
|
||||
telegramChatId: text('telegramChatId'),
|
||||
telegramApiUrl: text('telegramApiUrl'),
|
||||
notifyPaymentExpiryEnabled: integer('notifyPaymentExpiryEnabled'),
|
||||
notifyNewTariffsEnabled: integer('notifyNewTariffsEnabled'),
|
||||
telegramMessageThreadId: text('telegramMessageThreadId'),
|
||||
|
||||
@@ -196,6 +196,7 @@ CREATE TABLE IF NOT EXISTS settings (
|
||||
customFields TEXT,
|
||||
telegramBotToken TEXT,
|
||||
telegramChatId TEXT,
|
||||
telegramApiUrl TEXT,
|
||||
notifyPaymentExpiryEnabled INTEGER,
|
||||
notifyNewTariffsEnabled INTEGER,
|
||||
telegramMessageThreadId TEXT,
|
||||
|
||||
Reference in New Issue
Block a user