diff --git a/app/logic/Mail/IMAP/IMAPAccount.ts b/app/logic/Mail/IMAP/IMAPAccount.ts index cb22e7b4..e5227c26 100644 --- a/app/logic/Mail/IMAP/IMAPAccount.ts +++ b/app/logic/Mail/IMAP/IMAPAccount.ts @@ -6,6 +6,7 @@ import { ConnectError, LoginError } from "../../Abstract/Account"; import { SpecialFolder } from "../Folder"; import { assert, SpecificError } from "../../util/util"; import { Lock } from "../../util/Lock"; +import { Throttle } from "../../util/Throttle"; import { sanitize } from "../../../../lib/util/sanitizeDatatypes"; import { appName, appVersion, siteRoot } from "../../build"; import { ArrayColl, MapColl, type Collection } from "svelte-collections"; @@ -22,6 +23,7 @@ export class IMAPAccount extends MailAccount { pollIntervalMinutes = 10; protected connections = new MapColl(); protected connectLock = new MapColl(); + throttle = new Throttle(50, 1); constructor() { super(); @@ -55,6 +57,7 @@ export class IMAPAccount extends MailAccount { } async connection(interactive = false, purpose = ConnectionPurpose.Main): Promise { + await this.throttle.throttle(); let conn = this.connections.get(purpose); if (conn) { return conn;