global update and global fix
This commit is contained in:
@@ -82,6 +82,7 @@ export interface PublicUser {
|
||||
isVerified?: boolean;
|
||||
verificationIcon?: string | null;
|
||||
canVerifyUsers?: boolean;
|
||||
canManageBots?: boolean;
|
||||
}
|
||||
|
||||
export interface AdminUser {
|
||||
@@ -237,6 +238,10 @@ export interface FamilyInviteCandidate {
|
||||
hasAvatar?: boolean;
|
||||
isVerified?: boolean;
|
||||
verificationIcon?: string | null;
|
||||
isBot?: boolean;
|
||||
botUsername?: string;
|
||||
botId?: string;
|
||||
ownerDisplayName?: string;
|
||||
}
|
||||
|
||||
export async function searchFamilyInviteUsers(groupId: string, query: string, token?: string | null) {
|
||||
@@ -662,6 +667,8 @@ export interface FamilyMember {
|
||||
hasAvatar: boolean;
|
||||
isVerified?: boolean;
|
||||
verificationIcon?: string | null;
|
||||
isBot?: boolean;
|
||||
botUsername?: string;
|
||||
}
|
||||
|
||||
export interface FamilyGroup {
|
||||
@@ -670,6 +677,27 @@ export interface FamilyGroup {
|
||||
name: string;
|
||||
hasAvatar: boolean;
|
||||
members?: FamilyMember[];
|
||||
botFatherAvailable?: boolean;
|
||||
}
|
||||
|
||||
export interface BotChatMessage {
|
||||
id: string;
|
||||
direction: 'in' | 'out';
|
||||
text: string;
|
||||
messageType: string;
|
||||
messageId: number;
|
||||
createdAt: string;
|
||||
replyMarkupJson?: string | null;
|
||||
}
|
||||
|
||||
export interface BotChatMeta {
|
||||
botId?: string;
|
||||
botOwnerId?: string;
|
||||
botUsername?: string;
|
||||
botDisplayName?: string;
|
||||
composerWebAppUrl?: string | null;
|
||||
composerMenuButtonJson?: string | null;
|
||||
manageWebAppUrl?: string;
|
||||
}
|
||||
|
||||
export interface FamilyInvite {
|
||||
@@ -702,6 +730,12 @@ export interface ChatPollOption {
|
||||
votedByMe: boolean;
|
||||
}
|
||||
|
||||
export interface ChatMessageReaction {
|
||||
emoji: string;
|
||||
count: number;
|
||||
reactedByMe: boolean;
|
||||
}
|
||||
|
||||
export interface ChatMessage {
|
||||
id: string;
|
||||
roomId: string;
|
||||
@@ -712,6 +746,7 @@ export interface ChatMessage {
|
||||
senderVerificationIcon?: string | null;
|
||||
type: string;
|
||||
content?: string;
|
||||
isEncrypted?: boolean;
|
||||
replyToId?: string;
|
||||
storageKey?: string;
|
||||
mimeType?: string;
|
||||
@@ -727,6 +762,7 @@ export interface ChatMessage {
|
||||
isAnonymous: boolean;
|
||||
options: ChatPollOption[];
|
||||
};
|
||||
reactions?: ChatMessageReaction[];
|
||||
}
|
||||
|
||||
export interface FamilyPresenceMember {
|
||||
@@ -758,6 +794,9 @@ export interface ChatRoom {
|
||||
groupId: string;
|
||||
type: string;
|
||||
name: string;
|
||||
peerUserId?: string;
|
||||
botUsername?: string;
|
||||
isE2E?: boolean;
|
||||
hasAvatar: boolean;
|
||||
createdById?: string;
|
||||
updatedAt: string;
|
||||
@@ -785,6 +824,43 @@ 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 addBotFatherToFamily(groupId: string, token?: string | null) {
|
||||
return apiFetch<FamilyMember>(`/family/groups/${groupId}/botfather`, { method: 'POST', body: '{}' }, token);
|
||||
}
|
||||
|
||||
export async function addBotToFamily(groupId: string, botId: string, token?: string | null) {
|
||||
return apiFetch<FamilyMember>(`/family/groups/${groupId}/bots`, { method: 'POST', body: JSON.stringify({ botId }) }, token);
|
||||
}
|
||||
|
||||
export async function fetchBotChatMessages(botRef: string, token?: string | null) {
|
||||
return apiFetch<{
|
||||
messages?: BotChatMessage[];
|
||||
botUsername?: string;
|
||||
botDisplayName?: string;
|
||||
botId?: string;
|
||||
botOwnerId?: string;
|
||||
composerWebAppUrl?: string;
|
||||
composerMenuButtonJson?: string;
|
||||
manageWebAppUrl?: string;
|
||||
}>(`/bots/by-username/${encodeURIComponent(botRef)}/messages`, {}, token);
|
||||
}
|
||||
|
||||
export async function sendBotMessage(botRef: string, text: string, token?: string | null) {
|
||||
return apiFetch<{ updateId?: number; messageId?: number; chatId?: string }>(
|
||||
`/bots/by-username/${encodeURIComponent(botRef)}/messages`,
|
||||
{ method: 'POST', body: JSON.stringify({ text }) },
|
||||
token
|
||||
);
|
||||
}
|
||||
|
||||
export async function submitBotCallback(botRef: string, messageId: number, callbackData: string, token?: string | null) {
|
||||
return apiFetch<{ updateId?: number; callbackQueryId?: string; messageId?: number }>(
|
||||
`/bots/by-username/${encodeURIComponent(botRef)}/callback`,
|
||||
{ method: 'POST', body: JSON.stringify({ messageId, callbackData }) },
|
||||
token
|
||||
);
|
||||
}
|
||||
|
||||
export async function fetchFamilyInvites(token?: string | null) {
|
||||
return apiFetch<{ invites?: FamilyInvite[] }>('/family/invites', {}, token);
|
||||
}
|
||||
@@ -845,6 +921,7 @@ export async function sendChatMessage(
|
||||
body: {
|
||||
type: string;
|
||||
content?: string;
|
||||
isEncrypted?: boolean;
|
||||
replyToId?: string;
|
||||
storageKey?: string;
|
||||
mimeType?: string;
|
||||
@@ -856,6 +933,111 @@ export async function sendChatMessage(
|
||||
return apiFetch<ChatMessage>(`/chat/rooms/${roomId}/messages`, { method: 'POST', body: JSON.stringify(body) }, token);
|
||||
}
|
||||
|
||||
export async function fetchUserE2EPublicKey(userId: string, token?: string | null) {
|
||||
return apiFetch<{ userId?: string; e2ePublicKey?: string }>(`/profile/users/${userId}/e2e-public-key`, {}, token);
|
||||
}
|
||||
|
||||
export async function setUserE2EPublicKey(userId: string, publicKey: string, token?: string | null) {
|
||||
return apiFetch<{ userId?: string; e2ePublicKey?: string }>(
|
||||
`/profile/users/${userId}/e2e-public-key`,
|
||||
{ method: 'PATCH', body: JSON.stringify({ publicKey }) },
|
||||
token
|
||||
);
|
||||
}
|
||||
|
||||
export interface ManagedBot {
|
||||
id: string;
|
||||
name: string;
|
||||
username: string;
|
||||
tokenPrefix?: string;
|
||||
description?: string | null;
|
||||
aboutText?: string | null;
|
||||
botPicUrl?: string | null;
|
||||
menuButtonJson?: string | null;
|
||||
webAppUrl?: string | null;
|
||||
isActive?: boolean;
|
||||
isSystemBot?: boolean;
|
||||
ownerId?: string;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
owner?: { id: string; displayName: string; username?: string };
|
||||
messageCount?: number;
|
||||
chatCount?: number;
|
||||
}
|
||||
|
||||
export interface AdminBotMetrics {
|
||||
totalBots?: number;
|
||||
activeBots?: number;
|
||||
blockedBots?: number;
|
||||
totalMessages?: number;
|
||||
totalChats?: number;
|
||||
}
|
||||
|
||||
export async function fetchAdminBots(
|
||||
params: { search?: string; page?: number; limit?: number },
|
||||
token?: string | null
|
||||
) {
|
||||
const query = new URLSearchParams();
|
||||
if (params.search?.trim()) query.set('search', params.search.trim());
|
||||
if (params.page) query.set('page', String(params.page));
|
||||
if (params.limit) query.set('limit', String(params.limit));
|
||||
const suffix = query.toString() ? `?${query.toString()}` : '';
|
||||
return apiFetch<{ bots?: ManagedBot[]; total?: number }>(`/admin/bots${suffix}`, {}, token);
|
||||
}
|
||||
|
||||
export async function fetchAdminBotMetrics(token?: string | null) {
|
||||
return apiFetch<AdminBotMetrics>('/admin/bots/metrics', {}, token);
|
||||
}
|
||||
|
||||
export async function setAdminBotActive(botId: string, isActive: boolean, token?: string | null) {
|
||||
return apiFetch<ManagedBot>(`/admin/bots/${botId}/active`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify({ isActive })
|
||||
}, token);
|
||||
}
|
||||
|
||||
export async function createE2ERoom(groupId: string, peerUserId: string, token?: string | null) {
|
||||
return apiFetch<ChatRoom>(`/chat/groups/${groupId}/e2e-rooms`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ peerUserId })
|
||||
}, token);
|
||||
}
|
||||
|
||||
export async function fetchMyBots(token?: string | null) {
|
||||
return apiFetch<{ bots?: ManagedBot[]; total?: number }>('/bots', {}, token);
|
||||
}
|
||||
|
||||
export async function createManagedBot(body: { name: string; username: string }, token?: string | null) {
|
||||
return apiFetch<{ bot?: ManagedBot; token?: string }>('/bots', { method: 'POST', body: JSON.stringify(body) }, token);
|
||||
}
|
||||
|
||||
export async function fetchBot(botId: string, token?: string | null) {
|
||||
return apiFetch<ManagedBot>(`/bots/${botId}`, {}, token);
|
||||
}
|
||||
|
||||
export async function updateManagedBot(botId: string, body: { name?: string; username?: string }, token?: string | null) {
|
||||
return apiFetch<ManagedBot>(`/bots/${botId}`, { method: 'PATCH', body: JSON.stringify(body) }, token);
|
||||
}
|
||||
|
||||
export async function updateManagedBotProfile(
|
||||
botId: string,
|
||||
body: {
|
||||
description?: string;
|
||||
aboutText?: string;
|
||||
botPicUrl?: string;
|
||||
menuButtonUrl?: string;
|
||||
menuButtonText?: string;
|
||||
menuButtonJson?: string;
|
||||
},
|
||||
token?: string | null
|
||||
) {
|
||||
return apiFetch<ManagedBot>(`/bots/${botId}/profile`, { method: 'PATCH', body: JSON.stringify(body) }, token);
|
||||
}
|
||||
|
||||
export async function revokeManagedBotToken(botId: string, token?: string | null) {
|
||||
return apiFetch<{ bot?: ManagedBot; token?: string }>(`/bots/${botId}/revoke-token`, { method: 'POST' }, token);
|
||||
}
|
||||
|
||||
export async function voteChatPoll(messageId: string, optionIds: string[], token?: string | null) {
|
||||
return apiFetch<ChatMessage>(`/chat/messages/${messageId}/vote`, { method: 'POST', body: JSON.stringify({ optionIds }) }, token);
|
||||
}
|
||||
@@ -872,6 +1054,24 @@ export async function deleteChatMessage(messageId: string, token?: string | null
|
||||
return apiFetch<ChatMessage>(`/chat/messages/${messageId}`, { method: 'DELETE' }, token);
|
||||
}
|
||||
|
||||
export async function toggleChatMessageReaction(messageId: string, emoji: string, token?: string | null) {
|
||||
return apiFetch<ChatMessage>(`/chat/messages/${messageId}/reactions`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ emoji })
|
||||
}, token);
|
||||
}
|
||||
|
||||
export async function forwardChatMessages(targetRoomId: string, messageIds: string[], token?: string | null) {
|
||||
return apiFetch<{ messages?: ChatMessage[] }>(`/chat/rooms/${targetRoomId}/forward`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ messageIds })
|
||||
}, token);
|
||||
}
|
||||
|
||||
export async function deleteChatRoom(roomId: string, token?: string | null) {
|
||||
return apiFetch<{ count?: number }>(`/chat/rooms/${roomId}`, { method: 'DELETE' }, token);
|
||||
}
|
||||
|
||||
export async function markChatRoomRead(roomId: string, lastMessageId: string | undefined, token?: string | null) {
|
||||
return apiFetch<{ count: number }>(`/chat/rooms/${roomId}/read`, {
|
||||
method: 'POST',
|
||||
@@ -879,6 +1079,10 @@ export async function markChatRoomRead(roomId: string, lastMessageId: string | u
|
||||
}, token);
|
||||
}
|
||||
|
||||
export async function reportChatTyping(roomId: string, token?: string | null) {
|
||||
return apiFetch<{ success?: boolean }>(`/chat/rooms/${roomId}/typing`, { method: 'POST' }, token);
|
||||
}
|
||||
|
||||
export async function fetchFamilyPresence(groupId: string, token?: string | null) {
|
||||
return apiFetch<FamilyPresence>(`/family/groups/${groupId}/presence`, {}, token);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user