@budibase/worker 1.2.5 → 1.2.6

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": "1.2.5",
4
+ "version": "1.2.6",
5
5
  "description": "Budibase background service",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -35,10 +35,10 @@
35
35
  "author": "Budibase",
36
36
  "license": "GPL-3.0",
37
37
  "dependencies": {
38
- "@budibase/backend-core": "^1.2.5",
39
- "@budibase/pro": "1.2.4",
40
- "@budibase/string-templates": "^1.2.5",
41
- "@budibase/types": "^1.2.5",
38
+ "@budibase/backend-core": "^1.2.6",
39
+ "@budibase/pro": "1.2.5",
40
+ "@budibase/string-templates": "^1.2.6",
41
+ "@budibase/types": "^1.2.6",
42
42
  "@koa/router": "8.0.8",
43
43
  "@sentry/node": "6.17.7",
44
44
  "@techpass/passport-openidconnect": "0.3.2",
@@ -101,5 +101,5 @@
101
101
  "./scripts/jestSetup.js"
102
102
  ]
103
103
  },
104
- "gitHead": "fe1a52ca497fd3440484bab2e91eaad54096f0ce"
104
+ "gitHead": "7aa3a20ecc0f6d0f4617c6e703bf4f6f1998071e"
105
105
  }
@@ -214,13 +214,13 @@ export const invite = async (ctx: any) => {
214
214
  }
215
215
 
216
216
  export const inviteMultiple = async (ctx: any) => {
217
- let { emails, userInfo } = ctx.request.body
217
+ let users = ctx.request.body
218
218
  let existing = false
219
219
  let existingEmail
220
- for (let email of emails) {
221
- if (await usersCore.getGlobalUserByEmail(email)) {
220
+ for (let user of users) {
221
+ if (await usersCore.getGlobalUserByEmail(user.email)) {
222
222
  existing = true
223
- existingEmail = email
223
+ existingEmail = user.email
224
224
  break
225
225
  }
226
226
  }
@@ -228,17 +228,18 @@ export const inviteMultiple = async (ctx: any) => {
228
228
  if (existing) {
229
229
  ctx.throw(400, `${existingEmail} already exists`)
230
230
  }
231
- if (!userInfo) {
232
- userInfo = {}
233
- }
234
- userInfo.tenantId = tenancy.getTenantId()
235
- const opts: any = {
236
- subject: "{{ company }} platform invitation",
237
- info: userInfo,
238
- }
239
231
 
240
- for (let i = 0; i < emails.length; i++) {
241
- await sendEmail(emails[i], EmailTemplatePurpose.INVITATION, opts)
232
+ for (let i = 0; i < users.length; i++) {
233
+ let userInfo = users[i].userInfo
234
+ if (!userInfo) {
235
+ userInfo = {}
236
+ }
237
+ userInfo.tenantId = tenancy.getTenantId()
238
+ const opts: any = {
239
+ subject: "{{ company }} platform invitation",
240
+ info: userInfo,
241
+ }
242
+ await sendEmail(users[i].email, EmailTemplatePurpose.INVITATION, opts)
242
243
  }
243
244
 
244
245
  ctx.body = {
@@ -32,10 +32,12 @@ function buildInviteValidation() {
32
32
 
33
33
  function buildInviteMultipleValidation() {
34
34
  // prettier-ignore
35
- return joiValidator.body(Joi.object({
36
- emails: Joi.array().required(),
37
- userInfo: Joi.object().optional(),
38
- }).required())
35
+ return joiValidator.body(Joi.array().required().items(
36
+ Joi.object({
37
+ email: Joi.string(),
38
+ userInfo: Joi.object().optional(),
39
+ })
40
+ ))
39
41
  }
40
42
 
41
43
  function buildInviteAcceptValidation() {
@@ -79,7 +81,7 @@ router
79
81
  controller.invite
80
82
  )
81
83
  .post(
82
- "/api/global/users/inviteMultiple",
84
+ "/api/global/users/multi/invite",
83
85
  adminOnly,
84
86
  buildInviteMultipleValidation(),
85
87
  controller.inviteMultiple