import axios from "axios"; import {Message} from "./types.ts"; export type SharingForm = { status: boolean; message: string; data: string; } export type ViewData = { name: string; username: string; time: string; messages: Message[]; }; export type ViewForm = { status: boolean; message: string; data: ViewData | null; } export async function shareConversation( id: number, refs: number[] = [-1], ): Promise { try { const resp = await axios.post("/conversation/share", { id, refs }); return resp.data; } catch (e) { return { status: false, message: (e as Error).message, data: "" }; } } export async function viewConversation( hash: string, ): Promise { try { const resp = await axios.get(`/conversation/view?hash=${hash}`); return resp.data as ViewForm; } catch (e) { return { status: false, message: (e as Error).message, data: null, } } }