feat(invites): add group/channel invite links and join by token

This commit is contained in:
2026-03-08 09:58:55 +03:00
parent cc70394960
commit f01bbda14e
11 changed files with 247 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
import { http } from "./http";
import type { Chat, ChatDetail, ChatMember, ChatMemberRole, ChatType, DiscoverChat, Message, MessageReaction, MessageType } from "../chat/types";
import type { Chat, ChatDetail, ChatInviteLink, ChatMember, ChatMemberRole, ChatType, DiscoverChat, Message, MessageReaction, MessageType } from "../chat/types";
import axios from "axios";
export interface ChatNotificationSettings {
@@ -215,6 +215,16 @@ export async function unpinChat(chatId: number): Promise<Chat> {
return data;
}
export async function createInviteLink(chatId: number): Promise<ChatInviteLink> {
const { data } = await http.post<ChatInviteLink>(`/chats/${chatId}/invite-link`);
return data;
}
export async function joinByInvite(token: string): Promise<Chat> {
const { data } = await http.post<Chat>("/chats/join-by-invite", { token });
return data;
}
export async function deleteMessage(messageId: number, forAll = false): Promise<void> {
await http.delete(`/messages/${messageId}`, { params: { for_all: forAll } });
}