@budibase/worker 3.4.17 → 3.4.19
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": "3.4.
|
|
4
|
+
"version": "3.4.19",
|
|
5
5
|
"description": "Budibase background service",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
"@types/koa__router": "12.0.4",
|
|
87
87
|
"@types/lodash": "4.14.200",
|
|
88
88
|
"@types/node-fetch": "2.6.4",
|
|
89
|
+
"@types/nodemailer": "^6.4.17",
|
|
89
90
|
"@types/server-destroy": "1.0.1",
|
|
90
91
|
"@types/supertest": "2.0.14",
|
|
91
92
|
"@types/uuid": "8.3.4",
|
|
@@ -114,5 +115,5 @@
|
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
117
|
},
|
|
117
|
-
"gitHead": "
|
|
118
|
+
"gitHead": "14e590f1e05dbcbe3f8fc9c871899f1ec2d73d2b"
|
|
118
119
|
}
|
|
@@ -24,10 +24,13 @@ export async function sendEmail(
|
|
|
24
24
|
invite,
|
|
25
25
|
attachments,
|
|
26
26
|
} = ctx.request.body
|
|
27
|
-
let user:
|
|
27
|
+
let user: User | undefined = undefined
|
|
28
28
|
if (userId) {
|
|
29
29
|
const db = tenancy.getGlobalDB()
|
|
30
|
-
user = await db.
|
|
30
|
+
user = await db.tryGet<User>(userId)
|
|
31
|
+
}
|
|
32
|
+
if (!user) {
|
|
33
|
+
ctx.throw(404, "User not found.")
|
|
31
34
|
}
|
|
32
35
|
const response = await sendEmailFn(email, purpose, {
|
|
33
36
|
workspaceId,
|
package/src/utilities/email.ts
CHANGED
|
@@ -13,7 +13,8 @@ import { configs, cache, objectStore } from "@budibase/backend-core"
|
|
|
13
13
|
import ical from "ical-generator"
|
|
14
14
|
import _ from "lodash"
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
import nodemailer from "nodemailer"
|
|
17
|
+
import SMTPTransport from "nodemailer/lib/smtp-transport"
|
|
17
18
|
|
|
18
19
|
const TEST_MODE = env.ENABLE_EMAIL_TEST_MODE && env.isDev()
|
|
19
20
|
const TYPE = TemplateType.EMAIL
|
|
@@ -26,7 +27,7 @@ const FULL_EMAIL_PURPOSES = [
|
|
|
26
27
|
]
|
|
27
28
|
|
|
28
29
|
function createSMTPTransport(config?: SMTPInnerConfig) {
|
|
29
|
-
let options:
|
|
30
|
+
let options: SMTPTransport.Options
|
|
30
31
|
let secure = config?.secure
|
|
31
32
|
// default it if not specified
|
|
32
33
|
if (secure == null) {
|
|
@@ -161,7 +162,7 @@ export async function sendEmail(
|
|
|
161
162
|
const code = await getLinkCode(purpose, email, opts.user, opts?.info)
|
|
162
163
|
let context = await getSettingsTemplateContext(purpose, code)
|
|
163
164
|
|
|
164
|
-
let message:
|
|
165
|
+
let message: Parameters<typeof transport.sendMail>[0] = {
|
|
165
166
|
from: opts?.from || config?.from,
|
|
166
167
|
html: await buildEmail(purpose, email, context, {
|
|
167
168
|
user: opts?.user,
|