@budibase/worker 2.3.21 → 2.3.23

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.3.21",
4
+ "version": "2.3.23",
5
5
  "description": "Budibase background service",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -36,10 +36,10 @@
36
36
  "author": "Budibase",
37
37
  "license": "GPL-3.0",
38
38
  "dependencies": {
39
- "@budibase/backend-core": "^2.3.21",
40
- "@budibase/pro": "2.3.21-alpha.1",
41
- "@budibase/string-templates": "^2.3.21",
42
- "@budibase/types": "^2.3.21",
39
+ "@budibase/backend-core": "^2.3.23",
40
+ "@budibase/pro": "2.3.22",
41
+ "@budibase/string-templates": "^2.3.23",
42
+ "@budibase/types": "^2.3.23",
43
43
  "@koa/router": "8.0.8",
44
44
  "@sentry/node": "6.17.7",
45
45
  "@techpass/passport-openidconnect": "0.3.2",
@@ -101,5 +101,5 @@
101
101
  "typescript": "4.7.3",
102
102
  "update-dotenv": "1.1.1"
103
103
  },
104
- "gitHead": "787d52bed1db701a6bb76dd26708ebedd495dafb"
104
+ "gitHead": "138bf63a3e1582064ec855e83108bed05861bd77"
105
105
  }
@@ -341,7 +341,7 @@ export const getUserInvites = async (ctx: any) => {
341
341
  let invites
342
342
  try {
343
343
  // Restricted to the currently authenticated tenant
344
- invites = await getInviteCodes([ctx.user.tenantId])
344
+ invites = await getInviteCodes()
345
345
  } catch (e) {
346
346
  ctx.throw(400, "There was a problem fetching invites")
347
347
  }
@@ -1,4 +1,5 @@
1
- import { redis, utils } from "@budibase/backend-core"
1
+ import { redis, utils, tenancy } from "@budibase/backend-core"
2
+ import env from "../environment"
2
3
 
3
4
  function getExpirySecondsForDB(db: string) {
4
5
  switch (db) {
@@ -129,10 +130,9 @@ export async function checkInviteCode(
129
130
  }
130
131
 
131
132
  /**
132
- Get all currently available user invitations.
133
- @return {Object[]} A list of all objects containing invite metadata
133
+ Get all currently available user invitations for the current tenant.
134
134
  **/
135
- export async function getInviteCodes(tenantIds?: string[]) {
135
+ export async function getInviteCodes() {
136
136
  const client = await getClient(redis.utils.Databases.INVITATIONS)
137
137
  const invites: any[] = await client.scan()
138
138
 
@@ -142,12 +142,9 @@ export async function getInviteCodes(tenantIds?: string[]) {
142
142
  code: invite.key,
143
143
  }
144
144
  })
145
- return results.reduce((acc, invite) => {
146
- if (tenantIds?.length && tenantIds.includes(invite.info.tenantId)) {
147
- acc.push(invite)
148
- } else {
149
- acc.push(invite)
150
- }
151
- return acc
152
- }, [])
145
+ if (!env.MULTI_TENANCY) {
146
+ return results
147
+ }
148
+ const tenantId = tenancy.getTenantId()
149
+ return results.filter(invite => tenantId === invite.info.tenantId)
153
150
  }