From 3ab48d8537c35d4c211560c52580c7651cccbcb9 Mon Sep 17 00:00:00 2001 From: lendry Date: Fri, 26 Jun 2026 16:43:17 +0300 Subject: [PATCH] fix docker for tauri app --- .../src/controllers/bot.controller.ts | 6 +- apps/api-gateway/src/dto/bot.dto.ts | 4 + .../components/family/family-bot-chat.tsx | 8 +- .../components/family/family-group-view.tsx | 8 +- apps/frontend/lib/api.ts | 9 +- .../src/domain/auth-grpc.controller.ts | 12 +-- .../src/domain/bot/bot-api.service.ts | 84 ++++++++++++++++--- .../src/domain/bot/bot-inbound.service.ts | 27 +++++- apps/sso-core/src/domain/chat.service.ts | 59 ++++++++----- apps/sso-core/src/domain/family.service.ts | 77 +++++++++++------ shared/proto/bot.proto | 2 + 11 files changed, 220 insertions(+), 76 deletions(-) diff --git a/apps/api-gateway/src/controllers/bot.controller.ts b/apps/api-gateway/src/controllers/bot.controller.ts index 723889d..b5bccab 100644 --- a/apps/api-gateway/src/controllers/bot.controller.ts +++ b/apps/api-gateway/src/controllers/bot.controller.ts @@ -36,9 +36,9 @@ export class BotController { @Get('by-username/:botRef/messages') @ApiOperation({ summary: 'История чата с ботом', description: 'Возвращает сообщения пользователя с ботом в хронологическом порядке.' }) - listBotMessages(@Headers('authorization') authorization: string | undefined, @Param('botRef') botRef: string) { + listBotMessages(@Headers('authorization') authorization: string | undefined, @Param('botRef') botRef: string, @Query('roomId') roomId?: string) { return this.auth(authorization).then((userId) => - firstValueFrom(this.core.bot.ListBotChatMessages({ userId, botRef })) + firstValueFrom(this.core.bot.ListBotChatMessages({ userId, botRef, roomId })) ); } @@ -54,7 +54,7 @@ export class BotController { @Body() dto: SubmitBotMessageDto ) { return this.auth(authorization).then((senderUserId) => - firstValueFrom(this.core.bot.SubmitBotInboundMessage({ senderUserId, botRef, text: dto.text })) + firstValueFrom(this.core.bot.SubmitBotInboundMessage({ senderUserId, botRef, text: dto.text, roomId: dto.roomId })) ); } diff --git a/apps/api-gateway/src/dto/bot.dto.ts b/apps/api-gateway/src/dto/bot.dto.ts index c068209..53c30ce 100644 --- a/apps/api-gateway/src/dto/bot.dto.ts +++ b/apps/api-gateway/src/dto/bot.dto.ts @@ -91,6 +91,10 @@ export class SubmitBotMessageDto { @IsString() @MinLength(1, { message: 'Текст сообщения не может быть пустым' }) text!: string; + + @IsOptional() + @IsString() + roomId?: string; } export class SubmitBotCallbackDto { diff --git a/apps/frontend/components/family/family-bot-chat.tsx b/apps/frontend/components/family/family-bot-chat.tsx index c3675da..c52b08f 100644 --- a/apps/frontend/components/family/family-bot-chat.tsx +++ b/apps/frontend/components/family/family-bot-chat.tsx @@ -46,6 +46,7 @@ interface FamilyBotChatProps { botRef: string; botName: string; token: string | null; + roomId?: string; className?: string; inputPlaceholder?: string; onOpenMiniApp?: (url: string) => void; @@ -56,6 +57,7 @@ export function FamilyBotChat({ botRef, botName, token, + roomId, className, inputPlaceholder = 'Сообщение боту', onOpenMiniApp, @@ -98,7 +100,7 @@ export function FamilyBotChat({ if (!token) return; setLoading(true); try { - const response = await fetchBotChatMessages(botRef, token); + const response = await fetchBotChatMessages(botRef, token, roomId); setMessages(response.messages ?? []); const menuButton = resolveComposerMenuButton({ composerMenuButtonJson: response.composerMenuButtonJson, @@ -119,7 +121,7 @@ export function FamilyBotChat({ } finally { setLoading(false); } - }, [botRef, onBotMetaChange, token]); + }, [botRef, onBotMetaChange, roomId, token]); useEffect(() => { void loadMessages(); @@ -240,7 +242,7 @@ export function FamilyBotChat({ } ]); try { - await sendBotMessage(botRef, text, token); + await sendBotMessage(botRef, text, token, roomId); await loadMessages(); } finally { setSending(false); diff --git a/apps/frontend/components/family/family-group-view.tsx b/apps/frontend/components/family/family-group-view.tsx index 6745be0..3206dbc 100644 --- a/apps/frontend/components/family/family-group-view.tsx +++ b/apps/frontend/components/family/family-group-view.tsx @@ -340,7 +340,7 @@ export function FamilyGroupView({ groupId }: { groupId: string }) { const myMembership = activeRoom?.members.find((member) => member.userId === user?.id); const isFamilyOwner = group?.ownerId === user?.id; const isChatCreator = activeRoom?.createdById === user?.id; - const canManageChatMembers = Boolean(isFamilyOwner || isChatCreator); + const canManageChatMembers = Boolean(isFamilyOwner || isChatCreator || activeRoomIsBot); const canManageActiveBot = Boolean( activeRoomIsBot && botChatMeta?.manageWebAppUrl && user?.id && botChatMeta.botOwnerId === user.id ); @@ -1518,6 +1518,7 @@ export function FamilyGroupView({ groupId }: { groupId: string }) { botRef={activeRoom.botUsername} botName={activeRoomTitle} token={token} + roomId={activeRoom.id} onBotMetaChange={setBotChatMeta} onOpenMiniApp={(url) => { setMiniAppTitle('Mini App'); @@ -2142,8 +2143,9 @@ export function FamilyGroupView({ groupId }: { groupId: string }) { const presence = presenceByUserId.get(member.userId); const canRemoveFromChat = canManageChatMembers && - activeRoom.type === 'GROUP' && + (activeRoom.type === 'GROUP' || activeRoom.type === 'BOT') && member.userId !== user?.id && + member.userId !== activeRoom.peerUserId && !(member.isChatCreator && !isFamilyOwner); const canRemoveFromFamily = isFamilyOwner && member.familyRole !== 'owner' && familyMember; @@ -2183,7 +2185,7 @@ export function FamilyGroupView({ groupId }: { groupId: string }) { ); })} - {activeRoom?.type === 'GROUP' && familyMembersNotInRoom.length > 0 ? ( + {(activeRoom?.type === 'GROUP' || activeRoom?.type === 'BOT') && familyMembersNotInRoom.length > 0 ? (