generated from n8n-io/n8n-nodes-starter
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mailbox): add "Get Quota" operation
(cherry picked from commit e5152ae)
- Loading branch information
1 parent
4764925
commit 62abb23
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
nodes/Imap/operations/mailbox/functions/MailboxGetQuota.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow'; | ||
import {ImapFlow} from 'imapflow'; | ||
import { IResourceOperationDef } from '../../../utils/CommonDefinitions'; | ||
import { getMailboxPathFromNodeParameter, parameterSelectMailbox } from '../../../utils/SearchFieldParameters'; | ||
|
||
export const getMailboxQuotaOperation: IResourceOperationDef = { | ||
operation: { | ||
name: 'Get Quota', | ||
value: 'getMailboxQuota', | ||
description: 'Get quota (space usage) of an account', | ||
}, | ||
parameters: [ | ||
{ | ||
...parameterSelectMailbox, | ||
description: 'Select the mailbox', | ||
hint: "Leave as INBOX unless your email provider supports per-folder quotas" | ||
}, | ||
], | ||
async executeImapAction(context: IExecuteFunctions, itemIndex: number, client: ImapFlow): Promise<INodeExecutionData[] | null> { | ||
let returnData: INodeExecutionData[] = []; | ||
const mailboxPath = getMailboxPathFromNodeParameter(context, itemIndex); | ||
|
||
let info = await client.getQuota(mailboxPath); | ||
if (info === false || info === undefined) { | ||
// do nothing, returnData is left as an empty array (0 items) | ||
} else { | ||
let item_json = JSON.parse(JSON.stringify(info)); | ||
returnData.push({ | ||
json: item_json, | ||
}); | ||
} | ||
return returnData; | ||
}, | ||
}; |