feat(bot): add /dashboard command and MINI_APP_URL config

- Add /dashboard command to BotFather registration alongside /app
- Add new MINI_APP_URL env var for dashboard URL (separate from CORS origins)
- Pass MINI_APP_URL and BOT_API_URL in CD workflow
- Update Terraform with new variable for future infrastructure deployments
This commit is contained in:
2026-03-17 02:17:11 +04:00
parent 58cf69b9b6
commit fcdd0f2aaf
11 changed files with 42 additions and 7 deletions

View File

@@ -25,6 +25,7 @@ export interface BotRuntimeConfig {
assistantRateLimitBurstWindowMs: number
assistantRateLimitRolling: number
assistantRateLimitRollingWindowMs: number
miniAppUrl?: string
}
function parsePort(raw: string | undefined): number {
@@ -103,6 +104,7 @@ export function getBotRuntimeConfig(env: NodeJS.ProcessEnv = process.env): BotRu
const schedulerSharedSecret = parseOptionalValue(env.SCHEDULER_SHARED_SECRET)
const schedulerOidcAllowedEmails = parseOptionalCsv(env.SCHEDULER_OIDC_ALLOWED_EMAILS)
const miniAppAllowedOrigins = parseOptionalCsv(env.MINI_APP_ALLOWED_ORIGINS)
const miniAppUrl = parseOptionalValue(env.MINI_APP_URL)
const purchaseTopicIngestionEnabled = databaseUrl !== undefined
@@ -174,6 +176,9 @@ export function getBotRuntimeConfig(env: NodeJS.ProcessEnv = process.env): BotRu
if (schedulerSharedSecret !== undefined) {
runtime.schedulerSharedSecret = schedulerSharedSecret
}
if (miniAppUrl !== undefined) {
runtime.miniAppUrl = miniAppUrl
}
const openaiApiKey = parseOptionalValue(env.OPENAI_API_KEY)
if (openaiApiKey !== undefined) {
runtime.openaiApiKey = openaiApiKey

View File

@@ -15,6 +15,7 @@ export const enBotTranslations: BotTranslationCatalog = {
pending_members: 'List pending household join requests',
approve_member: 'Approve a pending household member',
app: 'Open the Kojori mini app',
dashboard: 'Open the household dashboard',
keyboard: 'Toggle persistent dashboard button'
},
help: {

View File

@@ -15,6 +15,7 @@ export const ruBotTranslations: BotTranslationCatalog = {
pending_members: 'Показать ожидающие заявки на вступление',
approve_member: 'Подтвердить участника дома',
app: 'Открыть мини-приложение Kojori',
dashboard: 'Открыть дашборд дома',
keyboard: 'Вкл/выкл кнопку дашборда'
},
help: {

View File

@@ -13,6 +13,7 @@ export type TelegramCommandName =
| 'pending_members'
| 'approve_member'
| 'app'
| 'dashboard'
| 'keyboard'
export interface BotCommandDescriptions {
@@ -28,6 +29,7 @@ export interface BotCommandDescriptions {
pending_members: string
approve_member: string
app: string
dashboard: string
keyboard: string
}

View File

@@ -313,7 +313,13 @@ if (purchaseRepositoryClient && householdConfigurationRepositoryClient) {
if (runtime.financeCommandsEnabled) {
const financeCommands = createFinanceCommandsService({
householdConfigurationRepository: householdConfigurationRepositoryClient!.repository,
financeServiceForHousehold
financeServiceForHousehold,
...(runtime.miniAppUrl
? {
miniAppUrl: runtime.miniAppUrl,
botUsername: bot.botInfo?.username
}
: {})
})
financeCommands.register(bot)
@@ -343,9 +349,9 @@ if (householdConfigurationRepositoryClient) {
promptRepository: telegramPendingActionRepositoryClient.repository
}
: {}),
...(runtime.miniAppAllowedOrigins[0]
...(runtime.miniAppUrl
? {
miniAppUrl: runtime.miniAppAllowedOrigins[0]
miniAppUrl: runtime.miniAppUrl
}
: {}),
logger: getLogger('household-setup')
@@ -399,9 +405,9 @@ const reminderJobs = runtime.reminderJobsEnabled
})
},
reminderService,
...(runtime.miniAppAllowedOrigins[0]
...(runtime.miniAppUrl
? {
miniAppUrl: runtime.miniAppAllowedOrigins[0]
miniAppUrl: runtime.miniAppUrl
}
: {}),
...(bot.botInfo?.username

View File

@@ -24,7 +24,9 @@ const DEFAULT_COMMAND_NAMES = [
const PRIVATE_CHAT_COMMAND_NAMES = [
...DEFAULT_COMMAND_NAMES,
'anon',
'cancel'
'cancel',
'app',
'dashboard'
] as const satisfies readonly TelegramCommandName[]
const GROUP_CHAT_COMMAND_NAMES = DEFAULT_COMMAND_NAMES
const GROUP_MEMBER_COMMAND_NAMES = [