forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits

getMessages.ts20 lines, 763 bytesHistoryRawDownload
1import { appendPageParams, client } from "../client";
2import type { Page, PageParams } from "../client";
3import type { Message, MessageFolder } from "../client";
4
5export function getMessages(
6 folder: MessageFolder = "inbox",
7 options?: PageParams & { read?: boolean; q?: string }
8): Promise<Page<Message>> {
9 const params = new URLSearchParams();
10 params.set("folder", folder);
11 if (options?.read !== undefined) params.set("read", String(options.read));
12 // Free-text search is server-side; blank after trim means no filter.
13 const q = options?.q?.trim();
14 if (q) params.set("q", q);
15 appendPageParams(params, options);
16
17 const query = params.toString();
18 const url = query ? `/messages?${query}` : `/messages`;
19 return client<Page<Message>>(url);
20}