mirror of
https://github.com/bulwarkmail/native.git
synced 2026-11-01 16:05:39 +00:00
Merge branch 'fx/read2' into feat/stalwart-1.0
This commit is contained in:
@@ -311,6 +311,27 @@ describe('email operations', () => {
|
||||
mockRequest.mockReset();
|
||||
});
|
||||
|
||||
it("sends each account's own filter in the shared request", async () => {
|
||||
(jmapClient.getMaxCallsInRequest as ReturnType<typeof vi.fn>).mockReturnValueOnce(16);
|
||||
mockRequest.mockImplementation(async (calls: Array<[string, Record<string, unknown>, string]>) => ({
|
||||
methodResponses: calls.map(([name, , id]) => (name === 'Email/query'
|
||||
? [name, { ids: [], total: 0 }, id]
|
||||
: [name, { list: [] }, id])),
|
||||
}));
|
||||
const sort = [{ property: 'receivedAt', isAscending: false }];
|
||||
const own = { operator: 'AND', conditions: [{ text: 'x' }, { inMailboxOtherThan: ['trash'] }] };
|
||||
|
||||
await queryEmailPagesAcrossAccounts(
|
||||
[{ position: 0, sort, filter: own }, { accountId: 'g1', position: 0, sort }],
|
||||
{ limit: 10, filter: { text: 'x' } },
|
||||
);
|
||||
|
||||
expect(mockRequest).toHaveBeenCalledTimes(1);
|
||||
const queries = mockRequest.mock.calls[0][0].filter((c: unknown[]) => c[0] === 'Email/query');
|
||||
expect(queries.map((c: unknown[]) => (c[1] as { filter: unknown }).filter)).toEqual([own, { text: 'x' }]);
|
||||
mockRequest.mockReset();
|
||||
});
|
||||
|
||||
it('leaves Thread/get out unless asked, and targets a shared account', async () => {
|
||||
mockRequest.mockResolvedValue({
|
||||
methodResponses: [
|
||||
|
||||
+6
-1
@@ -543,6 +543,11 @@ export interface AccountPageTarget {
|
||||
accountId?: string;
|
||||
position: number;
|
||||
sort: Array<{ property: string; isAscending: boolean; keyword?: string }>;
|
||||
/**
|
||||
* This account's own filter, in place of the shared `options.filter`
|
||||
* (the default search leaves each account's own Trash and Junk out).
|
||||
*/
|
||||
filter?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export type AccountPage =
|
||||
@@ -573,7 +578,7 @@ export async function queryEmailPagesAcrossAccounts(
|
||||
position: target.position,
|
||||
limit,
|
||||
sort: target.sort,
|
||||
filter: options.filter,
|
||||
filter: target.filter ?? options.filter,
|
||||
accountId: target.accountId,
|
||||
});
|
||||
calls.push(['Email/query', args, `${index}:q`]);
|
||||
|
||||
Reference in New Issue
Block a user