diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-12-15 12:29:30 -0800 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-12-15 12:29:30 -0800 |
commit | 6f45fe5a10174fd33932d17dc056898f06466067 (patch) | |
tree | 733bdf08f762e09e1db2a44320ae17c096393086 /src/email.ts | |
parent | 8e5fabec3e216ef55927909368c4013235fba729 (diff) | |
download | uptime-6f45fe5a10174fd33932d17dc056898f06466067.tar.gz uptime-6f45fe5a10174fd33932d17dc056898f06466067.zip |
close the mailbox
Diffstat (limited to 'src/email.ts')
-rw-r--r-- | src/email.ts | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/email.ts b/src/email.ts index cf588f4..337572c 100644 --- a/src/email.ts +++ b/src/email.ts @@ -26,6 +26,7 @@ interface ImapClientI { opts: Record<string, any>, ) => Promise<boolean>; logout: () => Promise<void>; + mailboxClose: () => Promise<void>; } type Email = { @@ -287,7 +288,10 @@ export const perform = ( if (O.isSome(e.imap)) { const imap = e.imap.value; return pipe( - TE.tryCatch(() => imap.logout(), toError), + TE.tryCatch( + () => imap.mailboxClose().then(() => imap.logout()), + toError, + ), TE.flatMap(() => TE.left(e)), ); } @@ -295,8 +299,13 @@ export const perform = ( }, ({ mailboxLock, deleted, imap }) => { mailboxLock.release(); - imap.logout(); - return TE.right(deleted); + return pipe( + TE.tryCatch( + () => imap.mailboxClose().then(() => imap.logout()), + toError, + ), + TE.flatMap(() => TE.right(deleted)), + ); }, ), ); |