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:
@@ -2,6 +2,21 @@ import { z } from 'zod'
|
||||
import { customFieldsSchema } from './custom-fields.js'
|
||||
import { appSwitcherConfigSchema } from './app-switcher.js'
|
||||
|
||||
/** Cloud Bot API origin. Local telegram-bot-api: http://127.0.0.1:8081 or https via TLS proxy. */
|
||||
export const DEFAULT_TELEGRAM_API_URL = 'https://api.telegram.org'
|
||||
|
||||
export function normalizeTelegramApiUrl(raw?: string | null): string {
|
||||
const trimmed = String(raw ?? '').trim()
|
||||
if (!trimmed) return DEFAULT_TELEGRAM_API_URL
|
||||
return trimmed.replace(/\/+$/, '').replace(/\/bot$/i, '')
|
||||
}
|
||||
|
||||
export const telegramApiUrlSchema = z
|
||||
.string()
|
||||
.optional()
|
||||
.transform((value) => normalizeTelegramApiUrl(value))
|
||||
.pipe(z.string().url('Невалидный URL'))
|
||||
|
||||
export const settingsSchema = z.object({
|
||||
id: z.string().optional(),
|
||||
baseCurrency: z.string().optional(),
|
||||
@@ -15,6 +30,7 @@ export const settingsSchema = z.object({
|
||||
uptimeCheckIntervalMinutes: z.coerce.number().optional(),
|
||||
telegramBotToken: z.string().optional(),
|
||||
telegramChatId: z.string().optional(),
|
||||
telegramApiUrl: telegramApiUrlSchema,
|
||||
telegramMessageThreadId: z.string().optional(),
|
||||
notifyPaymentExpiryEnabled: z.boolean().optional(),
|
||||
notifyNewTariffsEnabled: z.boolean().optional(),
|
||||
@@ -36,6 +52,7 @@ export type Settings = z.infer<typeof settingsSchema>
|
||||
export const telegramTestBodySchema = z.object({
|
||||
telegramBotToken: z.string().optional(),
|
||||
telegramChatId: z.string().optional(),
|
||||
telegramApiUrl: z.string().url('Невалидный URL').or(z.literal('')).optional(),
|
||||
telegramMessageThreadId: z.string().optional(),
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user