fix: empty Trash for shared and group folders #387

This commit is contained in:
Linus Rath
2026-06-03 20:18:02 +02:00
parent 941fa15251
commit 44781f002c
4 changed files with 10 additions and 6 deletions
+1 -1
View File
@@ -109,7 +109,7 @@ export interface IJMAPClient {
accountId?: string,
): Promise<void>;
moveEmail(emailId: string, toMailboxId: string, accountId?: string): Promise<void>;
emptyMailbox(mailboxId: string): Promise<number>;
emptyMailbox(mailboxId: string, accountId?: string): Promise<number>;
markMailboxAsRead(mailboxId: string, accountId?: string): Promise<number>;
markAllAsRead(excludeMailboxIds?: string[], accountId?: string): Promise<number>;
markAsSpam(emailId: string, accountId?: string, markAsRead?: boolean): Promise<void>;
+4 -3
View File
@@ -1445,19 +1445,20 @@ export class JMAPClient implements IJMAPClient {
}
}
async emptyMailbox(mailboxId: string): Promise<number> {
async emptyMailbox(mailboxId: string, accountId?: string): Promise<number> {
const targetAccountId = accountId || this.accountId;
let totalDestroyed = 0;
let hasMore = true;
while (hasMore) {
const response = await this.request([
["Email/query", {
accountId: this.accountId,
accountId: targetAccountId,
filter: { inMailbox: mailboxId },
limit: 500,
}, "0"],
["Email/set", {
accountId: this.accountId,
accountId: targetAccountId,
"#destroy": { resultOf: "0", name: "Email/query", path: "/ids" },
}, "1"],
]);