@budibase/worker 2.24.2 → 2.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/worker",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.24.2",
4
+ "version": "2.26.0",
5
5
  "description": "Budibase background service",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -37,10 +37,10 @@
37
37
  "author": "Budibase",
38
38
  "license": "GPL-3.0",
39
39
  "dependencies": {
40
- "@budibase/backend-core": "2.24.2",
41
- "@budibase/pro": "2.24.2",
42
- "@budibase/string-templates": "2.24.2",
43
- "@budibase/types": "2.24.2",
40
+ "@budibase/backend-core": "2.26.0",
41
+ "@budibase/pro": "2.26.0",
42
+ "@budibase/string-templates": "2.26.0",
43
+ "@budibase/types": "2.26.0",
44
44
  "@koa/router": "8.0.8",
45
45
  "@techpass/passport-openidconnect": "0.3.2",
46
46
  "@types/global-agent": "2.1.1",
@@ -108,5 +108,5 @@
108
108
  }
109
109
  }
110
110
  },
111
- "gitHead": "9c6e0823094ac5bbf514d628152050bf25faf98d"
111
+ "gitHead": "a7b9a5e059543bc51a4d3393dd1f54bc98d61dec"
112
112
  }
@@ -1,5 +1,4 @@
1
1
  jest.unmock("node-fetch")
2
- jest.unmock("aws-sdk")
3
2
  import { TestConfiguration } from "../../../../tests"
4
3
  import { EmailTemplatePurpose } from "../../../../constants"
5
4
  import { objectStore } from "@budibase/backend-core"
@@ -6,8 +6,7 @@ import { processString } from "@budibase/string-templates"
6
6
  import { User, SendEmailOpts, SMTPInnerConfig } from "@budibase/types"
7
7
  import { configs, cache, objectStore } from "@budibase/backend-core"
8
8
  import ical from "ical-generator"
9
- import fetch from "node-fetch"
10
- import path from "path"
9
+ import _ from "lodash"
11
10
 
12
11
  const nodemailer = require("nodemailer")
13
12
 
@@ -165,39 +164,12 @@ export async function sendEmail(
165
164
  }),
166
165
  }
167
166
  if (opts?.attachments) {
168
- const attachments = await Promise.all(
169
- opts.attachments?.map(async attachment => {
170
- const isFullyFormedUrl =
171
- attachment.url.startsWith("http://") ||
172
- attachment.url.startsWith("https://")
173
- if (isFullyFormedUrl) {
174
- const response = await fetch(attachment.url)
175
- if (!response.ok) {
176
- throw new Error(`unexpected response ${response.statusText}`)
177
- }
178
- const fallbackFilename = path.basename(
179
- new URL(attachment.url).pathname
180
- )
181
- return {
182
- filename: attachment.filename || fallbackFilename,
183
- content: response?.body,
184
- }
185
- } else {
186
- const url = attachment.url
187
- const result = objectStore.extractBucketAndPath(url)
188
- if (result === null) {
189
- throw new Error("Invalid signed URL")
190
- }
191
- const { bucket, path } = result
192
- const readStream = await objectStore.getReadStream(bucket, path)
193
- const fallbackFilename = path.split("/").pop() || ""
194
- return {
195
- filename: attachment.filename || fallbackFilename,
196
- content: readStream,
197
- }
198
- }
199
- })
167
+ let attachments = await Promise.all(
168
+ opts.attachments?.map(objectStore.processAutomationAttachment)
200
169
  )
170
+ attachments = attachments.map(attachment => {
171
+ return _.omit(attachment, "path")
172
+ })
201
173
  message = { ...message, attachments }
202
174
  }
203
175