feat(bot): add observable notification management

This commit is contained in:
2026-03-24 03:58:00 +04:00
parent 7e9ae75a41
commit 83ffd7df72
18 changed files with 1267 additions and 58 deletions

View File

@@ -14,6 +14,18 @@ export interface BotWebhookServerOptions {
handler: (request: Request) => Promise<Response>
}
| undefined
miniAppUpdateNotification?:
| {
path?: string
handler: (request: Request) => Promise<Response>
}
| undefined
miniAppCancelNotification?:
| {
path?: string
handler: (request: Request) => Promise<Response>
}
| undefined
miniAppJoin?:
| {
path?: string
@@ -226,6 +238,10 @@ export function createBotWebhookServer(options: BotWebhookServerOptions): {
: `/${options.webhookPath}`
const miniAppAuthPath = options.miniAppAuth?.path ?? '/api/miniapp/session'
const miniAppDashboardPath = options.miniAppDashboard?.path ?? '/api/miniapp/dashboard'
const miniAppUpdateNotificationPath =
options.miniAppUpdateNotification?.path ?? '/api/miniapp/notifications/update'
const miniAppCancelNotificationPath =
options.miniAppCancelNotification?.path ?? '/api/miniapp/notifications/cancel'
const miniAppJoinPath = options.miniAppJoin?.path ?? '/api/miniapp/join'
const miniAppPendingMembersPath =
options.miniAppPendingMembers?.path ?? '/api/miniapp/admin/pending-members'
@@ -301,6 +317,14 @@ export function createBotWebhookServer(options: BotWebhookServerOptions): {
return await options.miniAppDashboard.handler(request)
}
if (options.miniAppUpdateNotification && url.pathname === miniAppUpdateNotificationPath) {
return await options.miniAppUpdateNotification.handler(request)
}
if (options.miniAppCancelNotification && url.pathname === miniAppCancelNotificationPath) {
return await options.miniAppCancelNotification.handler(request)
}
if (options.miniAppJoin && url.pathname === miniAppJoinPath) {
return await options.miniAppJoin.handler(request)
}