fix docker for tauri app
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 }) {
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{activeRoom?.type === 'GROUP' && familyMembersNotInRoom.length > 0 ? (
|
||||
{(activeRoom?.type === 'GROUP' || activeRoom?.type === 'BOT') && familyMembersNotInRoom.length > 0 ? (
|
||||
<Button className="mt-4 w-full rounded-xl" onClick={() => {
|
||||
setMembersOpen(false);
|
||||
setAddMembersOpen(true);
|
||||
|
||||
@@ -897,7 +897,8 @@ export async function sendFamilyInvite(groupId: string, payload: { inviteeUserId
|
||||
return apiFetch<FamilyInvite>(`/family/groups/${groupId}/invites`, { method: 'POST', body: JSON.stringify(payload) }, token);
|
||||
}
|
||||
|
||||
export async function fetchBotChatMessages(botRef: string, token?: string | null) {
|
||||
export async function fetchBotChatMessages(botRef: string, token?: string | null, roomId?: string) {
|
||||
const suffix = roomId ? `?roomId=${encodeURIComponent(roomId)}` : '';
|
||||
return apiFetch<{
|
||||
messages?: BotChatMessage[];
|
||||
botUsername?: string;
|
||||
@@ -907,13 +908,13 @@ export async function fetchBotChatMessages(botRef: string, token?: string | null
|
||||
composerWebAppUrl?: string;
|
||||
composerMenuButtonJson?: string;
|
||||
manageWebAppUrl?: string;
|
||||
}>(`/bots/by-username/${encodeURIComponent(botRef)}/messages`, {}, token);
|
||||
}>(`/bots/by-username/${encodeURIComponent(botRef)}/messages${suffix}`, {}, token);
|
||||
}
|
||||
|
||||
export async function sendBotMessage(botRef: string, text: string, token?: string | null) {
|
||||
export async function sendBotMessage(botRef: string, text: string, token?: string | null, roomId?: string) {
|
||||
return apiFetch<{ updateId?: number; messageId?: number; chatId?: string }>(
|
||||
`/bots/by-username/${encodeURIComponent(botRef)}/messages`,
|
||||
{ method: 'POST', body: JSON.stringify({ text }) },
|
||||
{ method: 'POST', body: JSON.stringify({ text, roomId }) },
|
||||
token
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user