Decrypt and Store PDF
This is an example to demonstrate custom actions.
👉 Edit this example in the playground.
- Config
- Script
{
"description": "The action `custom.decryptAndStorePdf` decrypts and stores a PDF file.",
"settings": {
"markProcessedMethod": "mark-read"
},
"global": {
"thread": {
"match": {
"query": "has:attachment -in:trash -in:drafts -in:spam after:{{date.now|formatDate('yyyy-MM-dd')}} is:unread subject:\"[GmailProcessor-Test] decryptPdf\""
}
}
},
"threads": [
{
"match": {
"query": "subject:([GmailProcessor-Test] decryptPdf)"
},
"attachments": [
{
"description": "Process all attachments named 'encrypted*.pdf'",
"match": {
"name": "(?<basename>encrypted.*)\\.pdf$"
},
"actions": [
{
"name": "attachment.storeDecryptedPdf",
"args": {
"location": "/GmailProcessor-Tests/e2e/advanced/{{message.date|formatDate('yyyy-MM-dd')}}/decrypted.pdf",
"conflictStrategy": "replace",
"password": "test"
}
}
]
}
]
}
]
}
function decryptPdfRun() {
const config = {
description:
"The action `custom.decryptAndStorePdf` decrypts and stores a PDF file.",
settings: {
markProcessedMethod: "mark-read",
},
global: {
thread: {
match: {
query:
"has:attachment -in:trash -in:drafts -in:spam after:{{date.now|formatDate('yyyy-MM-dd')}} is:unread subject:\"[GmailProcessor-Test] decryptPdf\"",
},
},
},
threads: [
{
match: {
query: "subject:([GmailProcessor-Test] decryptPdf)",
},
attachments: [
{
description: "Process all attachments named 'encrypted*.pdf'",
match: {
name: "(?<basename>encrypted.*)\\.pdf$",
},
actions: [
{
name: "attachment.storeDecryptedPdf",
args: {
location:
"/GmailProcessor-Tests/e2e/advanced/{{message.date|formatDate('yyyy-MM-dd')}}/decrypted.pdf",
conflictStrategy: "replace",
password: "test",
},
},
],
},
],
},
],
}
return GmailProcessorLib.run(config, "dry-run")
}
Source: decryptPdf.ts | Issues: #355 | PRs: #381